[英]Handle WM_CLOSE message send to C# Tray App
I found a couple of articles telling me how to make use of the WM_CLOSE message but never the less my application is the one who has to handle the WM_CLOSE message. 我发现了一些文章,告诉我如何使用WM_CLOSE消息,但从来没有我的应用程序是必须处理WM_CLOSE消息的人。
Is there a way to hook up the WM_CLOSE and handle it? 有没有办法挂钩WM_CLOSE并处理它? Because the WM_CLOSE only closes the tray icon but does not terminate the process itself ... 因为WM_CLOSE只关闭托盘图标但不终止进程本身...
Regards, 问候,
To do this you need to override the WndProc
method on the Form
which is the main tray icon and handle WM_CLOSE
要执行此操作,您需要覆盖Form
上的WndProc
方法,该方法是主托盘图标并处理WM_CLOSE
private const int WM_CLOSE = 0x0010;
protected override void WndProc(ref Message m) {
if (m.Msg == WM_CLOSE) {
// Close everything
}
base.WndProc(ref m);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.