Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC
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 21:26pm
Rate this: bad
good
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.
  Permalink  
Comments
Lal Miah at 26-Jan-13 22:40pm
   
Thanks it works, the frame window is getting the close command
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Here: http://msdn.microsoft.com/en-us/library/hh46df93%28v=vs.80%29.aspx[^].
 
Handle this callback for nID == SC_CLOSE.
 
—SA
  Permalink  
Comments
Lal Miah at 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 at 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
Lal Miah at 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 at 24-Jan-13 12:32pm
   
I see. If you do it correct, everything will work; and you will capture the closing event.
—SA
Argonia at 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
0 OriginalGriff 390
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 244
3 BillWoodruff 210
4 Maciej Los 192
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 26 Jan 2013
Copyright © CodeProject, 1999-2014
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