Solved

preventing view from closing

Posted on 2002-07-25
4
280 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

776 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