dialog box IDCANCEL message when button is focused?
I have a dialog box with several buttons. I want to be able to use the escape key to close the dialog box. I'm currently using the IDCANCEL identified on the WM_COMMAND message to do this. However, if I have a button currently focused, pressing the escape key causes a system beep and doesn't send the IDCANCEL message. Is there a way to fix this without using Accelerators?
TIA
--Chris
# 1 Re: dialog box IDCANCEL message when button is focused?
Are you using MFC? If so, there shouldn't be any problem with having a button in focus and pressing ESC - the dlg should still go away.
Can you zip up your project and attach it, so we can take a look at your button handling code?
Arjay
Arjay at 2007-11-11 0:31:02 >

# 2 Re: dialog box IDCANCEL message when button is focused?
No, I'm not using MFC. The program is a DLL and does not have a message loop, which is why I can't use accelerators. I also have a system hotkey for a different function, but that also beeps when a button is focused. This won't run on your computer because you do not have the appropriate databases, and unfortunately I can't post them. I hope you will be able to help anyway.
TIA
--Chris
# 4 Re: dialog box IDCANCEL message when button is focused?
No, I'm not using MFC. The program is a DLL and does not have a message loop, which is why I can't use accelerators. I also have a system hotkey for a different function, but that also beeps when a button is focused.Sorry, I won't be able to help. What I can suggest is to create a couple of very simple projects (an exe and dll) that will help you isolate your issue. By doing this, you will be able to determine if there is a messaging problem in your approach, or if some other part of the application is interferring.
In other words, divide and conquer. Good luck.
Arjay
Arjay at 2007-11-11 0:34:10 >

# 6 Re: dialog box IDCANCEL message when button is focused?
Bingo! Thank you miteshpandey, that worked perfectly!
--Chris
# 7 Re: dialog box IDCANCEL message when button is focused?
I am curious. Does tabbing across buttons work ? I am suspecting, the message pump isn't calling IsDialogMessage.