?
Solved

Disabling close button on CMDIChildWnd

Posted on 1998-02-17
2
Medium Priority
?
386 Views
Last Modified: 2013-11-20
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.

0
Comment
Question by:dembowskis
[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

Accepted Solution

by:
Tommy Hui earned 400 total points
ID: 1316306
You'll need to catch the WM_SYSCOMMAND and check wParam parameter. If
  if ((wp & SC_CLOSE) == SC_CLOSE)
  {
    // ignore
  }
  else
  {
    // call base class
  }


0
 

Author Comment

by:dembowskis
ID: 1316307
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!!

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 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