Solved

Disable the Close system menu for MDI child window

Posted on 1997-11-14
2
519 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 10 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 137
Add content to output file 4 71
modThree challenge 4 103
haveThree challenge 22 123
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

762 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