Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message sent by the 'X' button in the title bar? (MFC C++)

Status
Not open for further replies.

huckfinn19

Programmer
May 16, 2003
90
CA
Hi, I need to execute some code before the the window gets destroyed in my MFC app when someone clicks the 'X' button on the top right corner...

How is it that I can intercept the message, or what function should I write my code in to make it execute BEFORE the window is destroyed?

I'm using a SDI type MFC Application...

Thanks

Simon
 
Since we are talking SDI (applicable on MDI as well) you could override the document's DeleteContents method, and perform clean up there (that's what it's for).

It will be called for whatever closing reason (ie not only the X button, but Alt+F4 etc. as well).

/Per
Nerdy signatures are as lame as the inconsistent stardates of STTNG.
 
Try over-riding the response to the WM_CLOSE message. This message is sent to the window before it is closed. In your over-ride you can intercept the messeage and do what ever you would like.

Hope this helps you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top