大佬们,请问如何实现一个C语言的托盘程序(Windows系统)
主要要实现的功能就是最小化到托盘和点击托盘显示窗口,这个“窗口”最好是图形化和黑窗口都行。感谢各位!
添加托盘
NOTIFYICONDATAW nd;
nd.cbSize = sizeof(nd);
nd.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;
nd.hWnd = m_hWnd;
nd.uID = IDR_MAINFRAME;
nd.hIcon = m_hIcon;
nd.uCallbackMessage = WM_TRAY;
wcscpy( nd.szTip, L"这里是提示信息" );
Shell_NotifyIconW( NIM_ADD, &nd );
WM_TRAY 是个自定义消息,比如我可以定义它为 #define WM_TRAY (WM_USER+1)
删除托盘
NOTIFYICONDATA nd;
nd.cbSize = sizeof(nd);
nd.uFlags = NIF_ICON;
nd.hWnd = m_hWnd;
nd.uID = IDR_MAINFRAME;
nd.hIcon = m_hIcon;
Shell_NotifyIcon( NIM_DELETE, &nd );
具体参见:https://docs.