Link to home
Start Free TrialLog in
Avatar of ehandojo
ehandojo

asked on

Disable the Close system menu for MDI child window

How can I disable the Close ("x") button of the MDI child window ?

I tried to add the following code in the OnCreate virtual function of my child frame class:

CMenu * psysmenu = GetSystemMenu( FALSE );
psysmenu->EnableMenuItem( SC_CLOSE, MF_DISABLED | MF_BYCOMMAND | MF_GRAYED );

It worked as long as the child window is not maximized, but if the child window is maximized then the "x" button is not disabled.
Avatar of Tommy Hui
Tommy Hui

You can try catching the WM_SYSCOMMAND and checking if (WPARAM & SC_CLOSE) == SC_CLOSE. If it is, then don't call the base class.
ASKER CERTIFIED SOLUTION
Avatar of galkin
galkin

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