Click here to Skip to main content
13,194,103 members (49,028 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello everyone,
I always get good help from this site.

This time i am in a situation where I need to check before I close the tabbed window.

the window class is inherited from CWnd class

So, when user request for window close, I need to check if any thread is running or not, if running i want to prompt the user. if user want i want to close the window in proper manner without.

I am not having the manner problem. But I am failing to find out how to cancel the window getting close. both of OnClose and OnDestroy return void. how to handle this thing?
Posted 23-Jan-13 20:26pm
Lal Miah-519
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Your CCDRProcessView might not receiving onClose message at all. your tabbed view window is created from the CMDIChildWndEx(if we are using the same...........). And probably your CMDIChildWndEx window is receiving your onClose command. I checked on my machine.
Lal Miah 26-Jan-13 22:40pm
Thanks it works, the frame window is getting the close command
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Handle this callback for nID == SC_CLOSE.

Lal Miah 24-Jan-13 3:04am
It might sound stupid, but in my case StaticLoadCDR not being called.


void CCDRProcessView::OnSysCommand(UINT nID, LPARAM lParam)
int i=1;
CWnd::OnSysCommand( nID, lParam);
Sorry, I don't know what's StatricLoadCDR... I don't see how just adding one extra...

Wait a minute! Such a bug!
You always return, because if(i) is always true! This function body makes no sense at all. I told you what to do: compare nID with SC_CLOSE. Doh...

Got it?

Lal Miah 24-Jan-13 3:36am
This was a test code. I was hopping OnSysCommand will be called. I know var i is true, cause that was what I wanted. I wanted to see after I press close button the window wont get closed.

the definition of CCDRProcessView is as below:
class CCDRProcessView:public CWnd
Sergey Alexandrovich Kryukov 24-Jan-13 12:32pm
I see. If you do it correct, everything will work; and you will capture the closing event.
Argonia 25-Jan-13 8:01am
I think you should catch the WM_CLOSE, WM_QUIT and so on(be sure to check all closing messages) in your class for tabbed window in the function PreTranslateMessage. About that function which was suggested by Sergey. It works only if you close your window from the Control menu(The small buttons in the upper right corner of the app).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171018.2 | Last Updated 26 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100