Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable the Close system menu for MDI child window

Posted on 1997-11-14
2
Medium Priority
?
545 Views
Last Modified: 2013-11-19
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.
0
Comment
Question by:ehandojo
2 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1310008
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.
0
 
LVL 7

Accepted Solution

by:
galkin earned 30 total points
ID: 1310009
You must resiter your window class with style CS_NOCLOSE. If you use MFC overwrite your frame PreCreateWindow and register new class by calling AfxRegisterWndClass(CS_NOCLOSE);. You can add other styles using bitwise OR operator. then assign class name returned by AfxRegisterWndClass to lpszClass field of CREATESTRUCT structure and call base class PreCreateWindow implementation.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question