preventing view from closing

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
LVL 1
OvermindAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
RolandAZConnect With a Mentor Commented:
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
 
jkrCommented:
Try to override 'DestroyWindow()' for your view class and return FALSE if you don't want it to close.
0
 
OvermindAuthor Commented:
DestroyWindow() doesn't get called either.
0
 
OvermindAuthor Commented:
CChildFrame::OnClose doesn't seem to work, but CChildFrame::DestroyWindow works perfectly.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.