处理WM_CLOSE消息发送到C#托盘应用程序 [英] Handle WM_CLOSE message send to C# Tray App

查看:229
本文介绍了处理WM_CLOSE消息发送到C#托盘应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现一对夫妇的文章告诉我如何使用WM_CLOSE消息,但从来没有少我的应用程序是谁拥有处理WM_CLOSE消息的人。

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? Because the WM_CLOSE only closes the tray icon but does not terminate the process itself ...

问候,

推荐答案

要做到这一点,你需要重写表格<关于的WndProc 方法/ code>这是主要的任务栏图标和处理 WM_CLOSE

To do this you need to override the WndProc method on the Form which is the main tray icon and handle 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);
}

这篇关于处理WM_CLOSE消息发送到C#托盘应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆