From 176e52e14fd0358a7f26ca8d7b0205244dfde2e7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 23 May 2018 23:29:25 +0300 Subject: no need to initialize pcli variable in each plugin (only in Clist_*) --- src/core/stdclist/src/clistmenus.cpp | 2 +- src/core/stdclist/src/clistopts.cpp | 2 +- src/core/stdclist/src/cluiopts.cpp | 66 ++++++++++++++++++------------------ src/core/stdclist/src/init.cpp | 17 +++++----- 4 files changed, 43 insertions(+), 44 deletions(-) (limited to 'src/core/stdclist') diff --git a/src/core/stdclist/src/clistmenus.cpp b/src/core/stdclist/src/clistmenus.cpp index afdb4c8da7..9ac72f36e2 100644 --- a/src/core/stdclist/src/clistmenus.cpp +++ b/src/core/stdclist/src/clistmenus.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static INT_PTR CloseAction(WPARAM, LPARAM) { if (Miranda_OkToExit()) - DestroyWindow(pcli->hwndContactList); + DestroyWindow(g_CLI.hwndContactList); return(0); } diff --git a/src/core/stdclist/src/clistopts.cpp b/src/core/stdclist/src/clistopts.cpp index 623787e931..65e6f790fb 100644 --- a/src/core/stdclist/src/clistopts.cpp +++ b/src/core/stdclist/src/clistopts.cpp @@ -178,7 +178,7 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP Clist_TrayIconIconsChanged(); Clist_LoadContactTree(); /* this won't do job properly since it only really works when changes happen */ - pcli->pfnInvalidateDisplayNameCacheEntry(INVALID_CONTACT_ID); /* force reshuffle */ + g_CLI.pfnInvalidateDisplayNameCacheEntry(INVALID_CONTACT_ID); /* force reshuffle */ return TRUE; } break; diff --git a/src/core/stdclist/src/cluiopts.cpp b/src/core/stdclist/src/cluiopts.cpp index f4607ada42..6d1f00ddd3 100644 --- a/src/core/stdclist/src/cluiopts.cpp +++ b/src/core/stdclist/src/cluiopts.cpp @@ -168,11 +168,11 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L wchar_t title[256]; GetDlgItemText(hwndDlg, IDC_TITLETEXT, title, _countof(title)); db_set_ws(NULL, "CList", "TitleText", title); - SetWindowText(pcli->hwndContactList, title); + SetWindowText(g_CLI.hwndContactList, title); } - pcli->pfnLoadCluiGlobalOpts(); - SetWindowPos(pcli->hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_ONTOP) ? HWND_TOPMOST : HWND_NOTOPMOST, + g_CLI.pfnLoadCluiGlobalOpts(); + SetWindowPos(g_CLI.hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_ONTOP) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); if (IsDlgButtonChecked(hwndDlg, IDC_TOOLWND)) { @@ -180,50 +180,50 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L // See http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_programming/taskbar.asp WINDOWPLACEMENT p; p.length = sizeof(p); - GetWindowPlacement(pcli->hwndContactList, &p); - ShowWindow(pcli->hwndContactList, SW_HIDE); - SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, - GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) & ~WS_EX_APPWINDOW | WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE); - SetWindowPlacement(pcli->hwndContactList, &p); + GetWindowPlacement(g_CLI.hwndContactList, &p); + ShowWindow(g_CLI.hwndContactList, SW_HIDE); + SetWindowLongPtr(g_CLI.hwndContactList, GWL_EXSTYLE, + GetWindowLongPtr(g_CLI.hwndContactList, GWL_EXSTYLE) & ~WS_EX_APPWINDOW | WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE); + SetWindowPlacement(g_CLI.hwndContactList, &p); } else - SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) & ~WS_EX_TOOLWINDOW | WS_EX_APPWINDOW); + SetWindowLongPtr(g_CLI.hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(g_CLI.hwndContactList, GWL_EXSTYLE) & ~WS_EX_TOOLWINDOW | WS_EX_APPWINDOW); if (IsDlgButtonChecked(hwndDlg, IDC_ONDESKTOP)) { HWND hProgMan = FindWindow(L"Progman", nullptr); if (hProgMan) - SetParent(pcli->hwndContactList, hProgMan); + SetParent(g_CLI.hwndContactList, hProgMan); } else - SetParent(pcli->hwndContactList, nullptr); + SetParent(g_CLI.hwndContactList, nullptr); if (IsDlgButtonChecked(hwndDlg, IDC_SHOWCAPTION)) { - int style = GetWindowLongPtr(pcli->hwndContactList, GWL_STYLE) | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; - SetWindowLongPtr(pcli->hwndContactList, GWL_STYLE, style); + int style = GetWindowLongPtr(g_CLI.hwndContactList, GWL_STYLE) | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; + SetWindowLongPtr(g_CLI.hwndContactList, GWL_STYLE, style); } else { - SetWindowLongPtr(pcli->hwndContactList, GWL_STYLE, - GetWindowLongPtr(pcli->hwndContactList, GWL_STYLE) & ~(WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX)); + SetWindowLongPtr(g_CLI.hwndContactList, GWL_STYLE, + GetWindowLongPtr(g_CLI.hwndContactList, GWL_STYLE) & ~(WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX)); } if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SHOWMAINMENU)) - SetMenu(pcli->hwndContactList, nullptr); + SetMenu(g_CLI.hwndContactList, nullptr); else - SetMenu(pcli->hwndContactList, pcli->hMenuMain); + SetMenu(g_CLI.hwndContactList, g_CLI.hMenuMain); - SetWindowPos(pcli->hwndContactList, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - RedrawWindow(pcli->hwndContactList, nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE); + SetWindowPos(g_CLI.hwndContactList, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); + RedrawWindow(g_CLI.hwndContactList, nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE); - if (IsIconic(pcli->hwndContactList) && BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_TOOLWND)) - ShowWindow(pcli->hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_MIN2TRAY) ? SW_HIDE : SW_SHOW); + if (IsIconic(g_CLI.hwndContactList) && BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_TOOLWND)) + ShowWindow(g_CLI.hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_MIN2TRAY) ? SW_HIDE : SW_SHOW); if (IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT)) { - SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) | WS_EX_LAYERED); - SetLayeredWindowAttributes(pcli->hwndContactList, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "AutoAlpha", SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA); + SetWindowLongPtr(g_CLI.hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(g_CLI.hwndContactList, GWL_EXSTYLE) | WS_EX_LAYERED); + SetLayeredWindowAttributes(g_CLI.hwndContactList, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "AutoAlpha", SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA); } else - SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) & ~WS_EX_LAYERED); + SetWindowLongPtr(g_CLI.hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(g_CLI.hwndContactList, GWL_EXSTYLE) & ~WS_EX_LAYERED); - SendMessage(pcli->hwndContactTree, WM_SIZE, 0, 0); //forces it to send a cln_listsizechanged + SendMessage(g_CLI.hwndContactTree, WM_SIZE, 0, 0); //forces it to send a cln_listsizechanged return TRUE; } @@ -283,22 +283,22 @@ static INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L db_set_b(NULL, "CLUI", "SBarRightClk", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_RIGHTMIRANDA)); db_set_b(NULL, "CLUI", "EqualSections", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_EQUALSECTIONS)); db_set_b(NULL, "CLUI", "SBarBevel", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SBPANELBEVEL)); - pcli->pfnLoadCluiGlobalOpts(); + g_CLI.pfnLoadCluiGlobalOpts(); if (db_get_b(NULL, "CLUI", "ShowGrip", 1) != (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWGRIP)) { - HWND parent = GetParent(pcli->hwndStatus); + HWND parent = GetParent(g_CLI.hwndStatus); int flags = WS_CHILD | CCS_BOTTOM; db_set_b(NULL, "CLUI", "ShowGrip", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWGRIP)); - ShowWindow(pcli->hwndStatus, SW_HIDE); - DestroyWindow(pcli->hwndStatus); + ShowWindow(g_CLI.hwndStatus, SW_HIDE); + DestroyWindow(g_CLI.hwndStatus); flags |= db_get_b(NULL, "CLUI", "ShowSBar", 1) ? WS_VISIBLE : 0; flags |= db_get_b(NULL, "CLUI", "ShowGrip", 1) ? SBARS_SIZEGRIP : 0; - pcli->hwndStatus = CreateWindow(STATUSCLASSNAME, nullptr, flags, 0, 0, 0, 0, parent, nullptr, g_plugin.getInst(), nullptr); + g_CLI.hwndStatus = CreateWindow(STATUSCLASSNAME, nullptr, flags, 0, 0, 0, 0, parent, nullptr, g_plugin.getInst(), nullptr); } if (IsDlgButtonChecked(hwndDlg, IDC_SHOWSBAR)) - ShowWindow(pcli->hwndStatus, SW_SHOW); + ShowWindow(g_CLI.hwndStatus, SW_SHOW); else - ShowWindow(pcli->hwndStatus, SW_HIDE); - SendMessage(pcli->hwndContactList, WM_SIZE, 0, 0); + ShowWindow(g_CLI.hwndStatus, SW_HIDE); + SendMessage(g_CLI.hwndContactList, WM_SIZE, 0, 0); return TRUE; } break; diff --git a/src/core/stdclist/src/init.cpp b/src/core/stdclist/src/init.cpp index 94d4517491..fc49caac7a 100644 --- a/src/core/stdclist/src/init.cpp +++ b/src/core/stdclist/src/init.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" CMPlugin g_plugin; -CLIST_INTERFACE* pcli = nullptr, coreCli; +CLIST_INTERFACE coreCli; HIMAGELIST himlCListClc = nullptr; ///////////////////////////////////////////////////////////////////////////////////////// @@ -99,7 +99,7 @@ static int OnOptsInit(WPARAM wParam, LPARAM lParam) static INT_PTR GetStatusMode(WPARAM, LPARAM) { - return pcli->currentDesiredStatusMode; + return g_CLI.currentDesiredStatusMode; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -107,16 +107,15 @@ static INT_PTR GetStatusMode(WPARAM, LPARAM) extern "C" __declspec(dllexport) int CListInitialise() { - pcli = Clist_GetInterface(); - g_bSortByStatus = db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT); g_bSortByProto = db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT); - coreCli = *pcli; - pcli->hInst = g_plugin.getInst(); - pcli->pfnPaintClc = PaintClc; - pcli->pfnLoadClcOptions = LoadClcOptions; - pcli->pfnCompareContacts = CompareContacts; + Clist_GetInterface(); + coreCli = g_CLI; + g_CLI.hInst = g_plugin.getInst(); + g_CLI.pfnPaintClc = PaintClc; + g_CLI.pfnLoadClcOptions = LoadClcOptions; + g_CLI.pfnCompareContacts = CompareContacts; CreateServiceFunction(MS_CLIST_GETSTATUSMODE, GetStatusMode); -- cgit v1.2.3