Solved

how to prevent a mdi child from closing?

Posted on 2001-06-14
8
389 Views
Last Modified: 2013-11-20
how to prevent a mdi child from closig? i have tried disable the WS_SYSMENU but a chlid can still be closed by ctrl-f4.

thanks.
0
Comment
Question by:bunwong
[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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 6190868
u mean alt+F4, not Ctrl+F4

0
 
LVL 2

Accepted Solution

by:
MadYugoslav earned 100 total points
ID: 6190881
Override mesage handler for message WM_CLOSE.
0
 
LVL 6

Expert Comment

by:MichaelS
ID: 6190895
Set CS_NOCLOSE window style for you child window
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 42

Expert Comment

by:sedgwick
ID: 6190913
override WindowProc() as follow:
LRESULT WindowProc(
  UINT uMsg,      // message identifier
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter
);



LRESULT CDynamicControlsDlg::WindowProc(UINT uMsg,
WPARAM wParam,LPARAM lParam)
{
     if(uMsg == WM_CLOSE)
          return 0;

     return CDialog::WindowProc(uMsg,wParam,lParam);
}

good luck
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 6190926
sorry, for child frame its should look like this:
LRESULT CChildFrame::WindowProc(UINT uMsg,
WPARAM wParam,LPARAM lParam)
{
    if(uMsg == WM_CLOSE)
         return 0;

    return CMDIChildWnd::WindowProc(uMsg,wParam,lParam);
}

btw, when u press ALT+F4 the main frame receives the WM_CLOSE and shut down the application so u need to take this under consideration
0
 

Author Comment

by:bunwong
ID: 6190939
it works, i am amazed how simple it is. thanks MadYugoslav
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6190948
Thanks.
0
 
LVL 6

Expert Comment

by:MichaelS
ID: 6190974
>it works
yep, it works but how :)
user see the close button, press it and nothing happens. or even better, user can do nothing, no minimize, no maximaze.

The solution I proposed allows you to have close button but it's disabled and from that point it's clear that window can't be closed
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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