Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to prevent a mdi child from closing?

Posted on 2001-06-14
8
Medium Priority
?
393 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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 42

Expert Comment

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

0
 
LVL 2

Accepted Solution

by:
MadYugoslav earned 400 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 42

Expert Comment

by:Meir Rivkin
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:Meir Rivkin
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

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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month21 days, left to enroll

810 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