diff --git a/localization.c b/localization.c index 4ed9e43..701acc6 100644 --- a/localization.c +++ b/localization.c @@ -242,7 +242,7 @@ ShowLocalizedMsg(const UINT stringId, ...) va_end(args); } -static HICON +HICON LoadLocalizedIconEx(const UINT iconId, int cxDesired, int cyDesired) { LANGID langId = GetGUILanguage(); diff --git a/localization.h b/localization.h index f75d809..71996b8 100644 --- a/localization.h +++ b/localization.h @@ -27,6 +27,7 @@ PTSTR LoadLocalizedString(const UINT, ...); int LoadLocalizedStringBuf(PTSTR, const int, const UINT, ...); void ShowLocalizedMsg(const UINT, ...); int ShowLocalizedMsgEx(const UINT, LPCTSTR, const UINT, ...); +HICON LoadLocalizedIconEx(const UINT, int cx, int cy); HICON LoadLocalizedIcon(const UINT); HICON LoadLocalizedSmallIcon(const UINT); LPCDLGTEMPLATE LocalizedDialogResource(const UINT); diff --git a/tray.c b/tray.c index c7bac7f..2c32438 100644 --- a/tray.c +++ b/tray.c @@ -45,12 +45,32 @@ HMENU hMenu; HMENU hMenuConn[MAX_CONFIGS]; HMENU hMenuService; +HBITMAP hbmpConnecting; + NOTIFYICONDATA ni; extern options_t o; #define USE_NESTED_CONFIG_MENU ((o.config_menu_view == CONFIG_VIEW_AUTO && o.num_configs > 25) \ || (o.config_menu_view == CONFIG_VIEW_NESTED)) + +/* Create menu check bitmaps */ +static void +CreateBitmaps() +{ + if (hbmpConnecting) + return; + int cx = GetSystemMetrics(SM_CXMENUCHECK); + int cy = GetSystemMetrics(SM_CYMENUCHECK); + if (!hbmpConnecting) + { + HICON icon = LoadLocalizedIconEx(ID_ICO_CONNECTING, cx, cy); + ICONINFO iconinfo; + GetIconInfo(icon, &iconinfo); + hbmpConnecting = iconinfo.hbmColor; + } +} + /* Create popup menus */ void CreatePopupMenus() @@ -61,6 +81,8 @@ CreatePopupMenus() */ assert(o.num_groups > 0); + CreateBitmaps(); + for (int i = 0; i < o.num_configs; i++) { hMenuConn[i] = CreatePopupMenu(); @@ -425,7 +447,10 @@ void SetMenuStatusById(int i, conn_state_t state) { connection_t *c = &o.conn[i]; - BOOL checked = (state == connected || state == disconnecting); + int checked = 0; + + if (state == connected || state == disconnecting) checked = 1; + else if (state != disconnected) checked = 2; if (o.num_configs == 1) { @@ -463,6 +488,16 @@ SetMenuStatusById(int i, conn_state_t state) if (USE_NESTED_CONFIG_MENU && CONFIG_GROUP(c)) parent = CONFIG_GROUP(c); + if (checked == 1) + { + /* Connected: use system-default check mark */ + SetMenuItemBitmaps(parent->menu, pos, MF_BYPOSITION, NULL, NULL); + } + else if (checked == 2) + { + /* Connecting: use our custom check mark */ + SetMenuItemBitmaps(parent->menu, pos, MF_BYPOSITION, NULL, hbmpConnecting); + } CheckMenuItem(parent->menu, pos, MF_BYPOSITION | (checked ? MF_CHECKED : MF_UNCHECKED)); PrintDebug(L"Setting state of config %s checked = %d, parent %s, pos %d",