mhunter Гость
|
Добавлено: Чт Янв 03 2002 01:52 Заголовок сообщения: Re: С++ Может кто-то знает как |
|
|
Уже отвечал. Например см. код ниже: #define UWM_SYSTRAY (WM_USER + 1) // Sent to us by the systray #define NUM_TOOLTIPS 10 // Number of ToolTips in our table ... LRESULT CALLBACK wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { POINT pt; HMENU hmenu, hpopup; NOTIFYICONDATA nid;
switch (message) {
...
case UWM_SYSTRAY: // We are being notified of mouse activity over the icon switch (lParam) { case WM_RBUTTONUP: // Let's track a popup menu GetCursorPos(&pt); hmenu = LoadMenu(ghInst, MAKEINTRESOURCE(IDM_CONTEXTMAIN)); hpopup = GetSubMenu(hmenu, 0);
/* SetForegroundWindow and the ensuing null PostMessage is a workaround for a Windows 95 bug (see MSKB article Q135788, http://www.microsoft.com/kb/articles/q135/7/88.htm, I think). In typical Microsoft style this bug is listed as "by design". SetForegroundWindow also causes our MessageBox to pop up in front of any other application's windows. */ SetForegroundWindow(hwnd); /* We specifiy TPM_RETURNCMD, so TrackPopupMenu returns the menu selection instead of returning immediately and our getting a WM_COMMAND with the selection. You don't have to do it this way. */ switch (TrackPopupMenu(hpopup, // Popup menu to track TPM_RETURNCMD | // Return menu code TPM_RIGHTBUTTON, // Track right mouse button? pt.x, pt.y, // screen coordinates 0, // reserved hwnd, // owner NULL)) // LPRECT user can click in // without dismissing menu { case IDM_EXIT: DestroyWindow(hwnd); break; case IDM_MESSAGEBOX: MessageBox(hwnd, "Heh heh heh...", "Death", MB_TASKMODAL); break; } PostMessage(hwnd, 0, 0, 0); // see above DestroyMenu(hmenu); // Delete loaded menu and reclaim its resources break;
case WM_LBUTTONDBLCLK: SetForegroundWindow(hwnd); // Our MessageBox pops up in front MessageBox(hwnd, "You're cool.", "Hey", MB_TASKMODAL); break; |
|