From 520fca8c13037c9077e7d372c0d20a2364964ffb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 13 Jul 2018 17:32:08 +0300 Subject: Contacts lists: - duplicate IDR_CLISTMENU resources removed, the only copy remains in mir_app.dll; - local variable g_hMenuMain removed from Clist_Modern and replaced with g_clistApi.hMenuMain; - duplicate code removed from Clist_Modern (CLUI::CreateCluiFrames()) - fixes #1465 (StdClist: "Status" menu cannot change language on the fly); - fixes #1467 (Clist_blind: menu cannot change language on the fly); - fixes menu-related part in #1471 --- src/core/stdclist/res/resource.rc | 27 --------------------------- src/core/stdclist/src/resource.h | 1 - src/mir_app/res/resource.rc | 22 ++++++++++++++++++++++ src/mir_app/src/clui.cpp | 26 ++++++++++++++++++++++++-- 4 files changed, 46 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/core/stdclist/res/resource.rc b/src/core/stdclist/res/resource.rc index 4e32d4bcf2..0b367c5e78 100644 --- a/src/core/stdclist/res/resource.rc +++ b/src/core/stdclist/res/resource.rc @@ -347,33 +347,6 @@ IDC_HYPERLINKHAND CURSOR "hyperlin.cur" IDC_DROP CURSOR "dragcopy.cur" IDC_DROPUSER CURSOR "dropuser.cur" -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_CLISTMENU MENU -BEGIN - POPUP "&Main menu" - BEGIN - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_ICQ_EXIT - END - POPUP "&Status" - BEGIN - MENUITEM "&Offline\tCtrl+0", ID_STATUS_OFFLINE, CHECKED - MENUITEM "On&line\tCtrl+1", ID_STATUS_ONLINE - MENUITEM "&Away\tCtrl+2", ID_STATUS_AWAY - MENUITEM "&Not available\tCtrl+3", ID_STATUS_NA - MENUITEM "Occ&upied\tCtrl+4", ID_STATUS_OCCUPIED - MENUITEM "&Do not disturb\tCtrl+5", ID_STATUS_DND - MENUITEM "&Free for chat\tCtrl+6", ID_STATUS_FREECHAT - MENUITEM "&Invisible\tCtrl+7", ID_STATUS_INVISIBLE - MENUITEM "On the &phone\tCtrl+8", ID_STATUS_ONTHEPHONE - MENUITEM "Out to &lunch\tCtrl+9", ID_STATUS_OUTTOLUNCH - END -END - #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/core/stdclist/src/resource.h b/src/core/stdclist/src/resource.h index f9c37606a3..2bb3c4ef25 100644 --- a/src/core/stdclist/src/resource.h +++ b/src/core/stdclist/src/resource.h @@ -5,7 +5,6 @@ #define IDD_OPT_CLIST 126 #define IDC_DROP 183 #define IDD_OPT_HOTKEY 184 -#define IDR_CLISTMENU 199 #define IDC_HYPERLINKHAND 214 #define IDC_DROPUSER 215 #define IDD_OPT_CLUI 218 diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc index cc030252d6..f0f22abf34 100644 --- a/src/mir_app/res/resource.rc +++ b/src/mir_app/res/resource.rc @@ -1298,6 +1298,28 @@ BEGIN END END +IDR_CLISTMENU MENU +BEGIN + POPUP "&Main menu" + BEGIN + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_ICQ_EXIT + END + POPUP "&Status" + BEGIN + MENUITEM "&Offline\tCtrl+0", ID_STATUS_OFFLINE, CHECKED + MENUITEM "On&line\tCtrl+1", ID_STATUS_ONLINE + MENUITEM "&Away\tCtrl+2", ID_STATUS_AWAY + MENUITEM "&Not available\tCtrl+3", ID_STATUS_NA + MENUITEM "Occ&upied\tCtrl+4", ID_STATUS_OCCUPIED + MENUITEM "&Do not disturb\tCtrl+5", ID_STATUS_DND + MENUITEM "&Free for chat\tCtrl+6", ID_STATUS_FREECHAT + MENUITEM "&Invisible\tCtrl+7", ID_STATUS_INVISIBLE + MENUITEM "On the &phone\tCtrl+8", ID_STATUS_ONTHEPHONE + MENUITEM "Out to &lunch\tCtrl+9", ID_STATUS_OUTTOLUNCH + END +END + #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index 568586b417..0805220825 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -63,8 +63,10 @@ static int CluiModulesLoaded(WPARAM, LPARAM) MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof(mii); mii.fMask = MIIM_SUBMENU; + mii.hSubMenu = Menu_GetMainMenu(); SetMenuItemInfo(g_clistApi.hMenuMain, 0, TRUE, &mii); + mii.hSubMenu = Menu_GetStatusMenu(); SetMenuItemInfo(g_clistApi.hMenuMain, 1, TRUE, &mii); } @@ -85,6 +87,20 @@ static int CluiIconsChanged(WPARAM, LPARAM) return 0; } +static int CluiLangpackChanged(WPARAM, LPARAM) +{ + if (g_clistApi.hMenuMain) { + RemoveMenu(g_clistApi.hMenuMain, 0, MF_BYPOSITION); + RemoveMenu(g_clistApi.hMenuMain, 0, MF_BYPOSITION); + DestroyMenu(g_clistApi.hMenuMain); + } + + g_clistApi.hMenuMain = LoadMenuA(g_plugin.getInst(), MAKEINTRESOURCEA(IDR_CLISTMENU)); + TranslateMenu(g_clistApi.hMenuMain); + SetMenu(g_clistApi.hwndContactList, g_clistApi.hMenuMain); + return 0; +} + static HGENMENU hRenameMenuItem; static int MenuItem_PreBuild(WPARAM, LPARAM) @@ -265,7 +281,6 @@ int LoadCLUIModule(void) wndclass.hIcon = Skin_LoadIcon(SKINICON_OTHER_MIRANDA, true); wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); - wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_CLISTMENU); wndclass.lpszClassName = _T(MIRANDACLASS); wndclass.hIconSm = Skin_LoadIcon(SKINICON_OTHER_MIRANDA); RegisterClassEx(&wndclass); @@ -303,16 +318,21 @@ int LoadCLUIModule(void) g_clistApi.pfnOnCreateClc(); + HookEvent(ME_LANGPACK_CHANGED, CluiLangpackChanged); + CluiLangpackChanged(0, 0); + PostMessage(g_clistApi.hwndContactList, M_RESTORESTATUS, 0, 0); int state = db_get_b(0, "CList", "State", SETTING_STATE_NORMAL); - g_clistApi.hMenuMain = GetMenu(g_clistApi.hwndContactList); + if (!db_get_b(0, "CLUI", "ShowMainMenu", SETTING_SHOWMAINMENU_DEFAULT)) SetMenu(g_clistApi.hwndContactList, nullptr); + if (state == SETTING_STATE_NORMAL) ShowWindow(g_clistApi.hwndContactList, SW_SHOW); else if (state == SETTING_STATE_MINIMIZED) ShowWindow(g_clistApi.hwndContactList, SW_SHOWMINIMIZED); + SetWindowPos(g_clistApi.hwndContactList, db_get_b(0, "CList", "OnTop", SETTING_ONTOP_DEFAULT) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); @@ -1030,6 +1050,8 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM RemoveMenu(g_clistApi.hMenuMain, 0, MF_BYPOSITION); RemoveMenu(g_clistApi.hMenuMain, 0, MF_BYPOSITION); + DestroyMenu(g_clistApi.hMenuMain); + g_clistApi.hMenuMain = nullptr; if (g_clistApi.hwndStatus) { DestroyWindow(g_clistApi.hwndStatus); -- cgit v1.2.3