Which Form event to use to clean up before shutting down?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 69
Reputation: DotNetUser is an unknown quantity at this point 
Solved Threads: 0
DotNetUser DotNetUser is offline Offline
Junior Poster in Training

Which Form event to use to clean up before shutting down?

 
0
  #1
Sep 29th, 2005
I'm using Visual C++.NET. When the user clicked on the X in the upper right corner of my gui, I want to close my files and sockets before the gui terminates. Which form event would get triggered when the X is clicked? I don't know where to find the list of available Form events. In VB 6.0, Form_Terminate, Form_Unload, or Form_QueryUnload are events that may be used.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 219
Reputation: BountyX is an unknown quantity at this point 
Solved Threads: 8
BountyX's Avatar
BountyX BountyX is offline Offline
Code Guru

Re: Which Form event to use to clean up before shutting down?

 
0
  #2
Sep 30th, 2005
WM_CLOSE (specifically when the X button is clicked)
WM_DESTROY (when the window is destroyed)

Example of a Dialog:

BOOL CALLBACK ExampleDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)


{
switch (message){
case WM_INITDIALOG: {
// Almost like the dialogs constructor return TRUE; //Dialog will stay visible
}
case WM_CLOSE: {// Do stuff before closing the dialog
EndDialog(hDlg, IDCANCEL); break;
}
return FALSE; }

NOTE: the EndDialog usage passes in IDCANCEL. Becuase the WM_COMMAND case is not shown in this example, most likly you would pass in a 0 or 1 instead of IDCANCEL.
A Hacker's Mind:
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC