Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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.
 
Share this answer
 
Comments
[no name] 26-Jan-13 22:40pm    
Thanks it works, the frame window is getting the close command
Here: http://msdn.microsoft.com/en-us/library/hh46df93%28v=vs.80%29.aspx[^].

Handle this callback for nID == SC_CLOSE.

—SA
 
Share this answer
 
Comments
[no name] 24-Jan-13 3:04am    
It might sound stupid, but in my case StaticLoadCDR not being called.

BEGIN_MESSAGE_MAP(CCDRProcessView, CWnd)
ON_WM_SYSCOMMAND()
END_MESSAGE_MAP()

void CCDRProcessView::OnSysCommand(UINT nID, LPARAM lParam)
{
int i=1;
if(i)
{
return;
}
else
{
CWnd::OnSysCommand( nID, lParam);
}
}
Sergey Alexandrovich Kryukov 24-Jan-13 3:14am    
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?

—SA
[no name] 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.
—SA
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900