Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

preventing view from closing

Posted on 2002-07-25
4
Medium Priority
?
300 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
[X]
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
  • 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 750 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

670 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