SIMPLE: "x" in System menu
-
What is the event message when the user clicks the x in the system menu. Background: I have disabled OnCancel() and OnOK() so that in my dialog-based app the esc and return keys don't close the app. I have the OnFileExit (when user selects file exit) method calling EndDialog(IDOK) directly. What function is called when the user clicks on the x? Long and short of it is I dont want keyboard commands (other than alt navigation) to close the app.
-
What is the event message when the user clicks the x in the system menu. Background: I have disabled OnCancel() and OnOK() so that in my dialog-based app the esc and return keys don't close the app. I have the OnFileExit (when user selects file exit) method calling EndDialog(IDOK) directly. What function is called when the user clicks on the x? Long and short of it is I dont want keyboard commands (other than alt navigation) to close the app.
JKallen wrote: What function is called when the user clicks on the x? Have you looked at
OnClose()
?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
What is the event message when the user clicks the x in the system menu. Background: I have disabled OnCancel() and OnOK() so that in my dialog-based app the esc and return keys don't close the app. I have the OnFileExit (when user selects file exit) method calling EndDialog(IDOK) directly. What function is called when the user clicks on the x? Long and short of it is I dont want keyboard commands (other than alt navigation) to close the app.
The message
WM_SYSCOMMAND
, with the command idSC_CLOSE
rather than leaving it visible and making it non-functional. This sort of thing is confusing and frustrating to users.To hide: remove theWS_SYSMENU
style from the window. To disable: retrieve the system menu by callingGetSystemMenu()
, then disable and gray the SC_CLOSE option by callingEnableMenuItem()
. You should then disable the command (and also the Alt+F4 mnemonic)by intercepting theWM_SYSCOMMAND
message and avoiding the default behavior if the command ID isSC_CLOSE
.Shog9
I'm not the Jack of Diamonds... I'm not the six of spades. I don't know what you thought; I'm not your astronaut...
-
JKallen wrote: What function is called when the user clicks on the x? Have you looked at
OnClose()
?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Yes. The problem is esc and return call OnOK and OnCancel, so doing anything to OnClose wont change anything. I think the problem is that clicking the x calls OnCancel (or OnOK doesnt matter which for my purposes). I need a way to differentiate between hitting the return key and the esc key from clicking the x or selecting file close. I dont want to get into Virtual Keys right now. Im not at that stage in writing this application yet. I try to write applications in phases. It makes things much simpler when I add functionality in groups.
-
The message
WM_SYSCOMMAND
, with the command idSC_CLOSE
rather than leaving it visible and making it non-functional. This sort of thing is confusing and frustrating to users.To hide: remove theWS_SYSMENU
style from the window. To disable: retrieve the system menu by callingGetSystemMenu()
, then disable and gray the SC_CLOSE option by callingEnableMenuItem()
. You should then disable the command (and also the Alt+F4 mnemonic)by intercepting theWM_SYSCOMMAND
message and avoiding the default behavior if the command ID isSC_CLOSE
.Shog9
I'm not the Jack of Diamonds... I'm not the six of spades. I don't know what you thought; I'm not your astronaut...
OK That worked. I aggree with respect to irritating users. What I have done (which works) in case you are interested is 1) disabled the OnOK and OnCancel to address the user hitting the esc and return keys 2) created an event handler to deal with user clicking file exit that calls EndDialog(IDOK) 3) edited the OnSysCommand function so that if SC_CLOSE is the message, it calls EndDialog(IDOK) as well Exactly the result I was looking for. Thanks.
-
Yes. The problem is esc and return call OnOK and OnCancel, so doing anything to OnClose wont change anything. I think the problem is that clicking the x calls OnCancel (or OnOK doesnt matter which for my purposes). I need a way to differentiate between hitting the return key and the esc key from clicking the x or selecting file close. I dont want to get into Virtual Keys right now. Im not at that stage in writing this application yet. I try to write applications in phases. It makes things much simpler when I add functionality in groups.
JKallen wrote: I need a way to differentiate between hitting the return key and the esc key from clicking the x or selecting file close. Then implement the following handlers:
OnOK()
OnCancel()
OnClose()
DestroyWindow()and note when each are called (e.g., breakpoint, message box).
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow