Click here to Skip to main content
15,902,938 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Trying to get Target Folder from Folder Shortcut Pin
Mike203626-May-04 10:03
Mike203626-May-04 10:03 
QuestionIs It Possible to do this? Pin
Shuang. Wu25-May-04 18:44
Shuang. Wu25-May-04 18:44 
AnswerRe: Is It Possible to do this? Pin
Abin25-May-04 19:26
Abin25-May-04 19:26 
GeneralRe: Is It Possible to do this? Pin
Shuang. Wu25-May-04 21:56
Shuang. Wu25-May-04 21:56 
AnswerRe: Is It Possible to do this? Pin
Iain Clarke, Warrior Programmer26-May-04 1:19
Iain Clarke, Warrior Programmer26-May-04 1:19 
GeneralMFC Rich Edit Contrl and ASCII file Pin
addo21425-May-04 18:19
addo21425-May-04 18:19 
GeneralRe: MFC Rich Edit Contrl and ASCII file Pin
David Crow26-May-04 4:52
David Crow26-May-04 4:52 
GeneralMFC OnClose() behaviour Pin
J.B.25-May-04 17:03
J.B.25-May-04 17:03 
Hello guys,

I'm wondering if anyone could help me to better undestand the exact OnClose() behaviour.

To start clearly, I have an dialog-based application that has a child dialog with a Exit button. When the button is clicked, the child dialog can therefore notify to close the application by sending a message (SendMessage()) to a parent dialog's function, which leads OnClose(), the function looks like:
LRESULT ParentDlg::OnExitApp(WPARAM wParam, LPARAM lParam)
{
	OnClose();
	return 0;
}</code>


I need to do some clean-up before the application is closed, so I override the OnClose() function:
void ParentDlg::OnClose()
{
	DoSomeCleanUp();
	CDialog::OnClose();	// call base class handler
}</code>

MSDN says OnClose() that its default implementation calls DestroyWindow. So I call the base class handler CDialog::OnClose() at the end of overriden OnClose() and assumes that should call DestroyWindow(), which leads to ParentDlg::OnDestroy()

I run in debug mode and found that, if the application is to close by clicking on the "X" of the application, fair enough, OnClose() is called and it goes to OnDestroy() and the program exits (with return code code 2 (0x2) -- strange??). However, if it is to close via the Exit button in the child dialog, which goes through OnExitApp(), OnClose(), then OnDestroy() never gets called after and the program will not exit. Why is the behaviour different when both call CDialog::OnClose() eventually?

I later simply insert the code DestroyWindow(); to the OnClose() function and that made both call OnDestroy() and both now exit the program. However here that produces another different behaviour. The program return code is now code 0 (0x0). Can anyone explain?

Sorry for this lenthy post Unsure | :~
Thanks
GeneralRe: MFC OnClose() behaviour Pin
Bob Stanneveld25-May-04 21:09
Bob Stanneveld25-May-04 21:09 
GeneralRe: MFC OnClose() behaviour Pin
Diddy26-May-04 0:13
Diddy26-May-04 0:13 
GeneralRe: MFC OnClose() behaviour Pin
David Crow26-May-04 3:30
David Crow26-May-04 3:30 
GeneralRe: MFC OnClose() behaviour Pin
J.B.27-May-04 0:46
J.B.27-May-04 0:46 
GeneralVC.Net In VC6 Pin
Anonymous25-May-04 13:56
Anonymous25-May-04 13:56 
GeneralRe: VC.Net In VC6 Pin
Anonymous25-May-04 15:54
Anonymous25-May-04 15:54 
GeneralRe: VC.Net In VC6 Pin
Ryan Binns25-May-04 18:14
Ryan Binns25-May-04 18:14 
GeneralRe: VC.Net In VC6 Pin
Anonymous25-May-04 18:40
Anonymous25-May-04 18:40 
GeneralRe: VC.Net In VC6 Pin
Ryan Binns25-May-04 18:43
Ryan Binns25-May-04 18:43 
GeneralRe: VC.Net In VC6 Pin
Jim A. Johnson25-May-04 19:18
Jim A. Johnson25-May-04 19:18 
GeneralRe: VC.Net In VC6 Pin
Ryan Binns25-May-04 23:36
Ryan Binns25-May-04 23:36 
GeneralRe: VC.Net In VC6 Pin
Jim A. Johnson26-May-04 4:39
Jim A. Johnson26-May-04 4:39 
GeneralGetting Text from Seperate Dialog Pin
Eversman25-May-04 13:48
Eversman25-May-04 13:48 
GeneralRe: Getting Text from Seperate Dialog Pin
Gary R. Wheeler25-May-04 14:45
Gary R. Wheeler25-May-04 14:45 
GeneralRe: Getting Text from Seperate Dialog Pin
avenger_sb2525-May-04 18:10
avenger_sb2525-May-04 18:10 
GeneralVC++.NET compiler running in VC++6 Errors Pin
---Mark---25-May-04 13:31
---Mark---25-May-04 13:31 
GeneralRe: VC++.NET compiler running in VC++6 Errors Pin
Anonymous25-May-04 13:39
Anonymous25-May-04 13:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.