Link to home
Start Free TrialLog in
Avatar of dembowskis
dembowskis

asked on

Disabling close button on CMDIChildWnd

I am writing a MDI application that has multiple document templates.  On start up, there is one document type that I want to open and not let the user close/destroy.  I want to disable the close button (X) in the corner of the CMDIChildWnd.  I have seen how to use PreCreateWindow to change the style for the minimize and maximize controls;  but I haven't figured out how to disable the close.

ASKER CERTIFIED SOLUTION
Avatar of Tommy Hui
Tommy Hui

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
Avatar of dembowskis
dembowskis

ASKER

Well, that wasn't exactly the answer I was looking for.  But it was enough of a hint that I got going in the right direction. And since you saved me a lot of time, I graded it high.

Your response would ignore the SC_CLOSE, but my question was how do I -DISABLE- the close button.  Researching the information on WM_SYSCOMMAND and SC_CLOSE got me on the GetSysMenu method and the following solution, which I placed in the OnActivateMdiFrame:

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

Thank you!!