我必须WM_QUIT
在 WPF 中捕获消息,但有一个问题。
IntPtr windowHandle = (new WindowInteropHelper(this)).Handle;
HwndSource src = HwndSource.FromHwnd(windowHandle);
src.AddHook(new HwndSourceHook(WndProc));
WndProc 工作正常并捕获除WM_QUIT
.
Msdn 说:
WM_QUIT 消息与窗口无关,因此永远不会通过窗口的窗口过程接收。它仅由 GetMessage 或 PeekMessage 函数检索。
有什么方法可以在 WPF 中捕获此消息?也许与ComponentDispatcher
?
还有: http ://www.pinvoke.net/default.aspx/user32.getmessage
可以在C#环境中使用。
欢迎任何帮助。