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
Solved

preventing view from closing

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

789 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