让措施在前端显示和最小化时在系统栏里
措施缩成图标!
/*参数说明:hWnd,不消多说了吧?
uId,图标排在系统栏中的位置,设为0即可
hIcon,图标
s,鼠标移到图标上要显示的话
*/
/*留意:你必需自界说一个窗口动静MYWM_ICON,
#define MYWM_ICON (WM_APP+100)
在窗口轮回中响应该动静:
case MYWM_ICON:
switch(lParam)
{
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
}
以响应鼠标在该措施图标上的击键行动。
假如你想让措施只以图标方法放在系统栏,可以界说窗口属性为WS_EX_TOOLWINDOW或POPUP之类
*/
void PutToTaskBar(HWND hWnd,UINT uId,HICON hIcon,LPCTSTR s)
{
TrayMessage(hWnd, NIM_ADD, uId,NULL, s);
TrayMessage(hWnd, NIM_MODIFY, uId,hIcon, s);
}
BOOL TrayMessage(HWND hDlg, DWORD dwMessage, UINT uID, HICON hIcon, LPCTSTR lpszTip)
{
BOOL res;
//char szVTip[64];
NOTIFYICONDATA tnd;
tnd.cbSize = sizeof(NOTIFYICONDATA);
tnd.hWnd = hDlg;
tnd.uID = uID;
tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
tnd.uCallbackMessage = MYWM_ICON;
tnd.hIcon = hIcon;
wsprintf(tnd.szTip,lpszTip);
res = Shell_NotifyIcon(dwMessage, &tnd);
if (hIcon)
DestroyIcon(hIcon);
return res;
}