Link to home
Start Free TrialLog in
Avatar of erajoj
erajojFlag for Sweden

asked on

Disabling close button

Is there any way to disable (or even hide) a window caption's close button, i.e. the top right button of a ws_sysmenu style window. I can already prevent a window from closing, so that is not what I'm asking for.
I have seen MDI child windows with this button disabled, so there has to be a way?!
Since I don't ask a lot of questions, a good answer will be worth a bunch.

/// John
ASKER CERTIFIED SOLUTION
Avatar of trestan
trestan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use GetSystemMenu to access the Control menu for copying and modification. The GetMenuItemCount function determines the number of items in the specified menu. The RemoveMenu function deletes a menu item from the specified menu. The DrawMenuBar function redraws the menu bar of the specified window. It should be easy to compile them together.
Or simpler:
CMenu *MyMenu; MyMenu = GetSystemMenu(FALSE);
 MyMenu->EnableMenuItem(SC_CLOSE,MF_DISABLED);


Put the codes under the OnCreate() function. For MDI child windows, add member function for WM_CREATE message in CChildFrame class.
Avatar of erajoj

ASKER

Thanx a bunch for the swift answer!
This is for the Delphi group, hope you don't mind.

/// John