Problem with a button in an SDI application
-
Hi! I have a problem with a button I have created dynamically in an SDI application in MFC. Its purpose is to terminate the application (an Exit button). It works perfectly when I click on it, but what I want to do is make it close my application when I press the Enter key. It just doesn't work, even though the button has focus. It works when I have a dialog based application, but I'm not interested in that. I want it to be an SDI application. A solution I have found is to close the application by calling PostQuitMessage method when I press the Enter key and my button has focus, but I'm interested in a more simple and elegant way if possible. Any ideas would be greatly apreciated! Thanks in advance!
-
Hi! I have a problem with a button I have created dynamically in an SDI application in MFC. Its purpose is to terminate the application (an Exit button). It works perfectly when I click on it, but what I want to do is make it close my application when I press the Enter key. It just doesn't work, even though the button has focus. It works when I have a dialog based application, but I'm not interested in that. I want it to be an SDI application. A solution I have found is to close the application by calling PostQuitMessage method when I press the Enter key and my button has focus, but I'm interested in a more simple and elegant way if possible. Any ideas would be greatly apreciated! Thanks in advance!
One way is, make that button of type CMyButton, derived from CButton, handle WM_KEYDOWN message. -- modified at 3:00 Friday 1st September, 2006
Prasad Notifier using ATL