Solved

Disabling close button on CMDIChildWnd

Posted on 1998-02-17
2
376 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
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

680 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