Solved

preventing view from closing

Posted on 2002-07-25
4
276 Views
Last Modified: 2013-12-03
Hi

I'm writing an MDI application using MFC and I want to prevent an MDI child window from closing when there is a wrong value entered in one of the controls.

I tried catching WM_CLOSE of the view, but it doesn't work, the window just closes without my OnClose getting invoked.

Does anyone know how to solve this? There mustn't be any possibility left to close that window or quit the application (except killing the task ;-) when my view doesn't want to close.

Thanks
Overmind
0
Comment
Question by:Overmind
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 7177370
Try to override 'DestroyWindow()' for your view class and return FALSE if you don't want it to close.
0
 
LVL 1

Author Comment

by:Overmind
ID: 7177616
DestroyWindow() doesn't get called either.
0
 
LVL 1

Accepted Solution

by:
RolandAZ earned 250 total points
ID: 7183719
Hi Overmind,

Override your CChildFrame::OnClose or CChildFrame::DestroyWindow depending on your needs.
OnClose subsequently calls DestroyWindow.

You have to explicitly call your CView::DestroyWindow that's why it's not getting called.


Hope that's what you require!
Have fun!
Roland

0
 
LVL 1

Author Comment

by:Overmind
ID: 7293595
CChildFrame::OnClose doesn't seem to work, but CChildFrame::DestroyWindow works perfectly.
0

Featured Post

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!

Join & Write a Comment

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

746 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

12 Experts available now in Live!

Get 1:1 Help Now