Solved

how to prevent a mdi child from closing?

Posted on 2001-06-14
8
384 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: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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Get filename and folder into excel 7 67
maxBlock challenge 30 100
post4 challenge 28 83
scoreUp challenge 14 48
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. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

16 Experts available now in Live!

Get 1:1 Help Now