#define WM_TIMER_HIDEBALLOON (WM_USER+103) BOOL CUpdateDlg::ShowBalloonTip(LPCTSTR szMsg, LPCTSTR szTitle, UINT uTimeout, DWORD dwInfoFlags) { m_nid.cbSize=sizeof(NOTIFYICONDATA); m_nid.uFlags = NIF_INFO; m_nid.uTimeout = uTimeout;//10s~30s之间,不过好像无效,所以设置个Timer隐藏 m_nid.dwInfoFlags = dwInfoFlags; strcpy(m_nid.szInfo,szMsg ? szMsg : _T("")); strcpy(m_nid.szInfoTitle,szTitle ? szTitle : _T("")); BOOL bRet=Shell_NotifyIcon(NIM_MODIFY, &m_nid); //如果前面已经设置过这个Timer,则会重新开始计时 SetTimer(WM_TIMER_HIDEBALLOON,uTimeout,NULL); return bRet; } void CUpdateDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default switch (nIDEvent) { case WM_TIMER_HIDEBALLOON: m_nid.uFlags=NIF_INFO; strcpy(m_nid.szInfo,_T("")); strcpy(m_nid.szInfoTitle,_T("")); Shell_NotifyIcon(NIM_MODIFY, &m_nid); KillTimer(WM_TIMER_HIDEBALLOON); break; default : break; } CDialog::OnTimer(nIDEvent); }
托盘气泡很长时间才能消失,uTimeout没起到作用的解决办法
原文地址:http://webrobot.blog.51cto.com/3808306/1651407