Archived

This topic is now archived and is closed to further replies.

thuned

question about CDialog

Recommended Posts

i have instances of cdialogs running; i select and i can press enter or escape and the dialog closes. how do i make it so it doesn''t close w/ enter or escape like a normal application? do i overwrite the virtual functions and do something in them or do i use another class like cpropertypage ?

Share this post


Link to post
Share on other sites
Handle the OnCommand message of the CDialog. I.e. go to class wizard and select the CDialog class and create a function for OnCommand. Then in the OnCommand function you need to find out if the WPARAM parameter specifies a key was pressed and which one and if its escape or return (or whatever) you return true, if it isnt then you return CDialog::OnCommand(wParam, lParam);

I dont have time right now to figure out how to test if the WPARAM parameter is escape key down etc but this should help you along. Ill have a look later and if you havent got it by then ill write more.

Hope ive helped

Share this post


Link to post
Share on other sites
There is a KB article about this: Q122489. Basically, rename the controls to something other than IDOK and IDCANCEL, then just call OnOK() and OnCancel() from your BN_CLICKED message handler.

Share this post


Link to post
Share on other sites