static LRESULT CALLBACK notifier_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == TOKEN_MESSAGE_ID) { switch (lParam) { case NIN_SELECT: case NIN_KEYSELECT: { NOTIFYICONDATA idata; khm_int32 cmd = KHUI_ACTION_OPEN_APP; khc_read_int32(NULL, L"CredWindow\\NotificationAction", &cmd); khui_action_trigger(cmd, NULL); ZeroMemory(&idata, sizeof(idata)); Shell_NotifyIcon(NIM_SETFOCUS, &idata); } return 0; case WM_CONTEXTMENU: handle_context_menu(); return TRUE; default: return 0; } } else if (uMsg == WM_COMMAND) { switch (LOWORD(wParam)) { case ID_DEFAULT: { khm_int32 cmd; cmd = get_default_notifier_action(); khui_action_trigger(cmd, NULL); } return TRUE; case ID_SHOWHELP: { wchar_t helploc[MAX_PATH + MAX_PATH]; get_help_file(helploc, sizeof(helploc)); StringCbCat(helploc, sizeof(helploc), L"::index.html"); HtmlHelp(notifier_window, helploc, HH_DISPLAY_TOPIC, 0); } return TRUE; } } return DefWindowProc(hwnd, uMsg, wParam, lParam); }
static void handle_select(void) { NOTIFYICONDATA idata; khm_int32 cmd; cmd = get_default_notifier_action(); khui_action_trigger(cmd, NULL); ZeroMemory(&idata, sizeof(idata)); Shell_NotifyIcon(NIM_SETFOCUS, &idata); }
static LRESULT CALLBACK notifier_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == TOKEN_MESSAGE_ID) { switch (lParam) { case NIN_SELECT: case NIN_KEYSELECT: handle_select(); return TRUE; case WM_CONTEXTMENU: handle_context_menu(); return TRUE; default: return FALSE; } } else if (uMsg == WM_COMMAND) { switch (LOWORD(wParam)) { case ID_DEFAULT: { khm_int32 cmd; cmd = get_default_notifier_action(); khui_action_trigger(cmd, NULL); } return TRUE; case ID_SHOWHELP: { afs_html_help(notifier_window, L"::/html/welcome.htm", HH_DISPLAY_TOPIC, 0); } return TRUE; case ID_RELEASENOTES: { wchar_t relnotes[MAX_PATH]; if (get_release_notes(relnotes)) HtmlHelp(GetDesktopWindow(), relnotes, HH_DISPLAY_TOC, 0); } return TRUE; } } return DefWindowProc(hwnd, uMsg, wParam, lParam); }
static void prepare_context_menu(HMENU hmenu) { khm_int32 cmd; wchar_t caption[128]; cmd = get_default_notifier_action(); if (cmd == KHUI_ACTION_NEW_CRED) LoadString(hResModule, IDS_ACT_NEW, caption, ARRAYLENGTH(caption)); else LoadString(hResModule, IDS_ACT_OPEN, caption, ARRAYLENGTH(caption)); ModifyMenu(hmenu, ID_DEFAULT, MF_STRING|MF_BYCOMMAND, ID_DEFAULT, caption); SetMenuDefaultItem(hmenu, ID_DEFAULT, FALSE); }