Add system tray icon under WINAPI implementation
#define idi_icon 600 // This is an icon ID for identity this icon
#define wm_notifyicon WM_USER 5 // Defines the message value here
NOTIFYICONDATA nd; nd.cbSize = sizeof (NOTIFYICONDATA); nd.hWnd = hwnd; // window handle nd.uID = IDI_ICON; nd.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nd.uCallbackMessage = WM_NOTIFYICON; nd.hIcon = Hicon; // is an icon handle STRCPY (Nd.sztip, "Icon prompt"); shell_notifyicon (nim_add, & nd); // Add icon to nim_add,
/ / Modify the icon type with nim_modify, delete the icon with nim_delete
Receive message can be added in the message callback function
Case WM_Notifyicon: IF ((wparam == idi_icon) && (lparam == wm_rbuttondown) {// Display Menu ShowMenu (HDLG, Loword (WPARAM), HiWord (WPARAM));} Return True; Break;
Display menu part
SetForegroundWindow (hwnd); // must add this sentence, hwnd assigns handle TRACKPOPUPMENU (Htmenu, 0, Pos.x, Pos.y, 0, hwnd, 0); // HTMENU is HMENU (menu handle)