Re: How do I intercept a close event?
From: Tinius (Tinius_at_discussions.microsoft.com)
Date: 01/13/05
- Next message: Mats-Lennart Hansson: "Re: Parsing string"
- Previous message: Claire: "Re: Configurations, do they work properly?"
- In reply to: Branimir Giurov [C# MVP]: "Re: How do I intercept a close event?"
- Next in thread: Sean Hederman: "Re: How do I intercept a close event?"
- Reply: Sean Hederman: "Re: How do I intercept a close event?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 13 Jan 2005 08:11:05 -0800
Hi Branimir and thanks for the suggestion
I tried what you suggested and its works fine for detecting when the User
closes the app. The WM_CLOSE is received directly after MainForm_Closing gets
executed.
I still am in the situation where I cannot find a way of determining when
the App is closed via Shutdown.
Tinius
"Branimir Giurov [C# MVP]" wrote:
> Hi Tinius,
>
> I think that the easiest way of capturing the close event of the form, is
> in fact to capture the WM_CLOSE message that's being send to the form through
> the message loop of the OS. Here's an easy way for doing that
>
> //insert the following code inside your main form class:
>
> const int WM_CLOSE = 16;
>
> protected override void WndProc(ref Message m)
> {
> base.WndProc (ref m);
>
> if ( WM_CLOSE == m.Msg )
> {
> //closing
> Trace.WriteLine(Application.ExecutablePath + " is exiting !!!");
> }
> }
>
> Cheers,
> Branimir
>
> Branimir Giurov
> C# MVP, MCSD, MCDBA, MCT
> CTO, BSH Ltd.
> www.sofiadev.org
>
- Next message: Mats-Lennart Hansson: "Re: Parsing string"
- Previous message: Claire: "Re: Configurations, do they work properly?"
- In reply to: Branimir Giurov [C# MVP]: "Re: How do I intercept a close event?"
- Next in thread: Sean Hederman: "Re: How do I intercept a close event?"
- Reply: Sean Hederman: "Re: How do I intercept a close event?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|