Disable window close [X] button
-
button so it won't accidently be hit, but I can't locate an easy way to do it. I did Google and found a couple of question/answer pages, but the solutions didn't work. They dealt with changing the system menu. Isn't there a style element or something easy? As I said, any help will be most appreciated. Thanks, Dave"You can say that again." -- Dept. of Redundancy Dept.
-
button so it won't accidently be hit, but I can't locate an easy way to do it. I did Google and found a couple of question/answer pages, but the solutions didn't work. They dealt with changing the system menu. Isn't there a style element or something easy? As I said, any help will be most appreciated. Thanks, Dave"You can say that again." -- Dept. of Redundancy Dept.
do it by Calling SetWindowLong(GWL_STYLE) Thanx TAKE CARE
-
do it by Calling SetWindowLong(GWL_STYLE) Thanx TAKE CARE
SetWindowLong? Thanks. What value should I use to disable the close button then? Dave "You can say that again." -- Dept. of Redundancy Dept.
-
button so it won't accidently be hit, but I can't locate an easy way to do it. I did Google and found a couple of question/answer pages, but the solutions didn't work. They dealt with changing the system menu. Isn't there a style element or something easy? As I said, any help will be most appreciated. Thanks, Dave"You can say that again." -- Dept. of Redundancy Dept.
-
button so it won't accidently be hit, but I can't locate an easy way to do it. I did Google and found a couple of question/answer pages, but the solutions didn't work. They dealt with changing the system menu. Isn't there a style element or something easy? As I said, any help will be most appreciated. Thanks, Dave"You can say that again." -- Dept. of Redundancy Dept.
take a look at my homepage under: http://www.code-diary.com/HTML/Diary/0001.htm greets, Jason
-
One solution is EnableMenuItem(). GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE, MF_DISABLED); Kuphryn
The problem I have with this approach is that as a child window, there is no system menu for it, and I get an unhandled exception. This is when I put these statements in the OnCreate handler of the child window. When I put this in for the main frame, then indeed it does disable the close, but for the main window, not for the child. Thanks, Dave "You can say that again." -- Dept. of Redundancy Dept.
-
The problem I have with this approach is that as a child window, there is no system menu for it, and I get an unhandled exception. This is when I put these statements in the OnCreate handler of the child window. When I put this in for the main frame, then indeed it does disable the close, but for the main window, not for the child. Thanks, Dave "You can say that again." -- Dept. of Redundancy Dept.
That should work anyways. See the doc for CWnd::GetSystemMenu. CWnd::GetSystemMenu CMenu* GetSystemMenu( BOOL bRevert ) const; Return Value Identifies a copy of the Control menu if bRevert is FALSE. If bRevert is TRUE, the return value is undefined. The returned pointer may be temporary and should not be stored for later use. Parameters bRevert Specifies the action to be taken. If bRevert is FALSE, GetSystemMenu returns a handle to a copy of the Control menu currently in use. This copy is initially identical to the Control menu but can be modified. If bRevert is TRUE, GetSystemMenu resets the Control menu back to the default state. The previous, possibly modified, Control menu, if any, is destroyed. The return value is undefined in this case. Remarks Allows the application to access the Control menu for copying and modification. Any window that does not use GetSystemMenu to make its own copy of the Control menu receives the standard Control menu. The pointer returned by the GetSystemMenu member function can be used with the CMenu::AppendMenu, CMenu::InsertMenu, or CMenu::ModifyMenu functions to change the Control menu. The Control menu initially contains items identified with various ID values such as SC_CLOSE, SC_MOVE, and SC_SIZE. Items on the Control menu generate WM_SYSCOMMAND messages. All predefined Control-menu items have ID numbers greater than 0xF000. If an application adds items to the Control menu, it should use ID numbers less than F000. Windows may automatically dim items on the standard Control menu. CWnd can carry out its own checking or dimming by responding to the WM_INITMENU messages, which are sent before any menu is displayed. John
-
The problem I have with this approach is that as a child window, there is no system menu for it, and I get an unhandled exception. This is when I put these statements in the OnCreate handler of the child window. When I put this in for the main frame, then indeed it does disable the close, but for the main window, not for the child. Thanks, Dave "You can say that again." -- Dept. of Redundancy Dept.
You should be able to create a system menu. In the PreCreate() function add the style for the system menu, then disable the clost button which was explained by the other users. hope this helps (I'm not sure it will though :-O)
A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.