Windows message WM_QUIT and WPF

494 Views Asked by At

I have to catch WM_QUIT message in WPF but there is a problem.

IntPtr windowHandle = (new WindowInteropHelper(this)).Handle;
HwndSource src = HwndSource.FromHwnd(windowHandle);
src.AddHook(new HwndSourceHook(WndProc));

WndProc works fine and catch all messages except WM_QUIT.

Msdn says:

The WM_QUIT message is not associated with a window and therefore will never be received through a window's window procedure. It is retrieved only by the GetMessage or PeekMessage functions.

Is there any way to catch this message in WPF? Maybe with ComponentDispatcher?

There is also: http://www.pinvoke.net/default.aspx/user32.getmessage

Which can be used in C# environment.

Any help would be welcome.

0

There are 0 best solutions below