很多程序希望它能在后台运行,这时需要最小化到托盘,所以就有编写最小化到托盘函数的必要了。
其实是用到了NOTIFYICONDATA 结构
void TuoPan(HWND hwnd)
{
NOTIFYICONDATA nid;
ZeroMemory(&nid, sizeof(nid));
HGLOBAL hResource = LoadResource ((HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),
FindResource ((HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),
TEXT ("Program"), TEXT ("Program")));
TCHAR *pText = (TCHAR *) LockResource (hResource) ;
nid.cbSize = sizeof(nid);
nid.hWnd = hwnd;
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
nid.uID = IDI_HP;
nid.uCallbackMessage = WM_CLICKBIT;
nid.hIcon = LoadIcon((HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE), MAKEINTRESOURCE(IDI_TUBIAO));
lstrcpy(nid.szTip, pText);
Shell_NotifyIcon(NIM_ADD, &nid);
}
//这时程序的一模块,希望能抛砖引玉