Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disabling close button on CMDIChildWnd

Posted on 1998-02-17
2
Medium Priority
?
390 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 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

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…
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

824 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