| | |
Which Form event to use to clean up before shutting down?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2005
Posts: 69
Reputation:
Solved Threads: 0
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.
WM_CLOSE (specifically when the X button is clicked)
WM_DESTROY (when the window is destroyed)
Example of a Dialog:
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.
WM_DESTROY (when the window is destroyed)
Example of a Dialog:
BOOL CALLBACK ExampleDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {switch (message){return FALSE; }case WM_INITDIALOG: {// Almost like the dialogs constructor return TRUE; //Dialog will stay visible}case WM_CLOSE: {// Do stuff before closing the dialogEndDialog(hDlg, IDCANCEL); break;}
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
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
![]() |
Similar Threads
- Why won't this code work? (VB.NET)
- hangman revised (VB.NET)
- form event problem (JavaScript / DHTML / AJAX)
- Closed event of a form (C#)
- Can u help me with hangman code in vb.net please :( (VB.NET)
- Populating a fields on a form base on a selected item from a droplist. (PHP)
- Patrickske: svchost/rpc crashes (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: C++
- Next Thread: Help with c++ program
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





