Solved

Disable the Close system menu for MDI child window

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 22
bobThere java chalenge 45 85
method notes when mouse over in eclipse 5 68
bigDiff challenge 17 75
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now