LRESULT CTryIconDriver::OnTrayNotify(WPARAM wParam, LPARAM lParam) { if(wParam != m_tnd.uID) return 0L; CMenu menu,*pSubMenu; if(LOWORD(lParam) == WM_RBUTTONUP) { if(!menu.LoadMenu(m_tnd.uID)) return 0; if(!(pSubMenu = menu.GetSubMenu(0))) return 0; ::SetMenuDefaultItem(pSubMenu->m_hMenu,0,TRUE); pSubMenu->ModifyMenu(0,MF_BYPOSITION|MF_STRING, (UINT)pSubMenu->GetMenuItemID(0),(IsWindowVisible(m_tnd.hWnd)?"Òþ²Ø´°¿Ú":"ÏÔʾ´°¿Ú")); CPoint pos; GetCursorPos(&pos); ::SetForegroundWindow(m_tnd.hWnd); ::TrackPopupMenu(pSubMenu->m_hMenu,0,pos.x,pos.y,0,m_tnd.hWnd,NULL); menu.DestroyMenu(); } else if(LOWORD(lParam) == WM_LBUTTONDBLCLK) { if(GetNotificationWnd()->IsWindowVisible()) return 1; if(!menu.LoadMenu(m_tnd.uID)) return 0; if(!(pSubMenu = menu.GetSubMenu(0))) return 0; GetNotificationWnd()->SetForegroundWindow(); GetNotificationWnd()->SendMessage(WM_COMMAND,pSubMenu->GetMenuItemID(0),0); menu.DestroyMenu(); } return 1; }
void CMsgThrd::KillCompNotifyThread(void) { SetEvent(m_hEventKillCompNotify); while (MsgWaitForMultipleObjects(1, &m_hEventCompNotifyKilled, FALSE, INFINITE, QS_SENDMESSAGE) == WAIT_OBJECT_0+1) { MSG msg; // must process any sent messages here to avoid deadlock! while (PeekMessage(&msg, GetNotificationWnd(), 0, 0, PM_REMOVE)) {} } m_pCompNotifyWorkerThread = NULL; return; }