944,110 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2214
  • C++ RSS
Sep 29th, 2005
0

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

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
DotNetUser is offline Offline
69 posts
since Jun 2005
Sep 30th, 2005
0

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

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.
Reputation Points: 28
Solved Threads: 9
Posting Whiz in Training
BountyX is offline Offline
222 posts
since Mar 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: C++
Next Thread in C++ Forum Timeline: Help with c++ program





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC