Solved

Disable the Close system menu for MDI child window

Posted on 1997-11-14
2
529 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

Industry Leaders: 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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

623 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