C++系统托盘唯一程序 [英] C++ system tray only program
问题描述
检查微软关于系统托盘图标的文档后(我能找到):
After checking Microsoft's documentation on system tray icons (that I could find):
我注意到需要一个窗口句柄 (HWND).这对我想要完成的事情来说非常糟糕,因为我正在寻找一个只对系统托盘做出反应的程序:它不会最小化"托盘的窗口,它只是使用通知(点击/右键单击图标)进行交互.
I've noticed that a window handle (HWND) is REQUIRED. This is very bad for what I'm trying to accomplish, as I'm looking to create a program that only reacts to the system tray: it doesn't "minimize" the window to the tray, it just uses notifications (clicking/right clicking on the icon) to interact.
我该怎么做?
推荐答案
Windows 7 SDK 包含一个名为 通知图标.此示例包含一行
The Windows 7 SDK contains an example called NotificationIcon. This example contains a line
ShowWindow(hwnd, nCmdShow);
在它的 wWinMain
函数中.这个调用的效果是你看到了一个程序窗口.
in its wWinMain
function. The effect of this call is that you see a program window.
只需将此行更改为
ShowWindow(hwnd, SW_HIDE);
隐藏程序窗口,只显示系统托盘中的图标.正如其他人指出的那样,该程序需要一个程序窗口,即使它不可见.
to hide the program window and only display the icon in the system tray. As others have pointed out the program needs a program window, even if it is not visible.
这篇关于C++系统托盘唯一程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!