15,978
社区成员




BOOL res;
HICON hicon;
hicon = LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCEA(m_bRun?IDI_STOP:IDI_LISTEN));
//设置托盘数据结构
m_Pallet_Struct.cbSize = sizeof(NOTIFYICONDATA);
m_Pallet_Struct.hWnd = ::AfxGetMainWnd()->m_hWnd;
m_Pallet_Struct.uID = MYICON;
m_Pallet_Struct.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;
m_Pallet_Struct.uCallbackMessage = MYWM_NOTIFYICON;
m_Pallet_Struct.hIcon = hicon;
m_Pallet_Struct.uTimeout = 600000;
lstrcpyn(m_Pallet_Struct.szTip,MYTIPX,sizeof(MYTIP));
res = Shell_NotifyIconA(NIM_ADD,&m_Pallet_Struct);
if(!res)
{
DWORD dwCode = GetLastError();
CString sTemp;
sTemp.Format(_T("添加任务栏图标失败,错误代码:%d"),dwCode);
AfxMessageBox(sTemp);
}
if(hicon)
DestroyIcon(hicon);
return res;
BOOL res = FALSE;
while(!res)
{
Sleep(1000);
res = Shell_NotifyIcon(NIM_ADD,&m_Pallet_Struct);
}