c++ - How to use CDialog::SetDefId with a non button control? -



i've come across cdialog::setdefid , while pretty easy , clear "pushbuttons" wanted use functionality non button control.i understand have press enter or return make dialog use id

if set nid 0 in cdialog::oninitdialog , have no default button setted dialog default cdialog::onok, if have default button setted, dialog push button expected.

the thing want make work non button control, if set nid control not pushbutton, dialog nothing if set message handler keydown event or nm_return, doesn't matter if control has focus or not, dialog still nothing if press enter or return.

how can make control default control without using stuff pretranslatemessage? , message sent control?

thanks in advance

yes, works buttons can use setfocus change focus other control:

bool cmydlg::oninitdialog() {     cdialog::oninitdialog();     getdlgitem(idc_check1)->setfocus();     return 0;  // return true  unless set focus control } 

in example ok button may still default button. enter key go default button, idok. space key change check box idc_check1.

there has default button. if don't want one, add fake button, lets idc_button1, , make default button , not visible, don't see default button (you can still add idc_button1 message map , decide enter key)


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -