Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Dialog boxes and CTRL+BREAK events

Evan_de_Kock
Beginner
716 Views

Dear All,

I have discovered accidentally that when using a (modal) dialog box equipped with the default CANCEL button (ID=IDCANCEL), a CTRL+BREAK event while the dialog box is still displayed causes the dialog to close and return the value that is associated with the CANCEL button. If a callback function for the CANCEL button is registered, then this function gets called when the CTRL+BREAK event occurs.

It there any way I can distinquish betweena CTRL+BREAK event and the CANCEL button actually being pressed?

Thanks for any help.

Evan de Kock

0 Kudos
2 Replies
Paul_Curtis
Valued Contributor I
716 Views
Quoting - Evan de Kock

...It there any way I can distinquish betweena CTRL+BREAK event and the CANCEL button actually being pressed?


You can do this by setting a keyboard hook (SetWindowsHookEx) and/or using RegisterHotKeys to send a WM_HOTKEY to your proc for system keys which are un-hookable.

However, it might be simpler to create your own cancel button with an ID other than the default ID_CANCEL.
0 Kudos
Evan_de_Kock
Beginner
716 Views
Quoting - Paul Curtis

You can do this by setting a keyboard hook (SetWindowsHookEx) and/or using RegisterHotKeys to send a WM_HOTKEY to your proc for system keys which are un-hookable.

However, it might be simpler to create your own cancel button with an ID other than the default ID_CANCEL.

Thanks Paul. I will definitely look into the option of setting up a keyboard hook. Furthermore, I have already implemented your alternative suggestion of creating my own cancel button with a ID different than ID_CANCEL. In fact, I have kept the default cancel button (IDCANCEL), but hidden, so that I can use a callback function for it to trap the CNTRL+BREAK event while the dialog is still open. Very dirty, but it works nicely...
0 Kudos
Reply