Solved

Disabling close button on CMDIChildWnd

Posted on 1998-02-17
2
345 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

14 Experts available now in Live!

Get 1:1 Help Now