From 14bdd09684eb98da73a0fe46882f883f109841d6 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 16 May 2018 13:47:00 +0300 Subject: AvatarHistory: cmplugin adaptation --- plugins/AvatarHistory/src/AvatarDlg.cpp | 6 +++--- plugins/AvatarHistory/src/AvatarHistory.cpp | 13 ++----------- plugins/AvatarHistory/src/icolib.cpp | 2 +- plugins/AvatarHistory/src/options.cpp | 2 +- plugins/AvatarHistory/src/popup.cpp | 2 +- plugins/AvatarHistory/src/stdafx.h | 10 +++++++--- 6 files changed, 15 insertions(+), 20 deletions(-) (limited to 'plugins') diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp index ed1bd5761b..262d0f60e3 100644 --- a/plugins/AvatarHistory/src/AvatarDlg.cpp +++ b/plugins/AvatarHistory/src/AvatarDlg.cpp @@ -66,7 +66,7 @@ public: static void __cdecl AvatarDialogThread(AvatarDialogData *data) { - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AVATARDLG), data->parent, AvatarDlgProc, (LPARAM)data); + DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_AVATARDLG), data->parent, AvatarDlgProc, (LPARAM)data); } int OpenAvatarDialog(MCONTACT hContact, char* fn) @@ -190,7 +190,7 @@ static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA } else break; - HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)); + HMENU menu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1)); HMENU submenu = GetSubMenu(menu, 0); TranslateMenu(submenu); @@ -520,7 +520,7 @@ int ShowSaveDialog(HWND hwnd, wchar_t* fn, MCONTACT hContact) OPENFILENAME ofn = { 0 }; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; - ofn.hInstance = hInst; + ofn.hInstance = g_plugin.getInst(); ofn.lpstrFilter = filter; diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index 371e873281..46affc4d63 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -23,14 +23,13 @@ Avatar History Plugin */ #include "stdafx.h" -HINSTANCE hInst; - DWORD mirVer; HANDLE hFolder = nullptr; wchar_t profilePath[MAX_PATH]; // database profile path (read at startup only) wchar_t basedir[MAX_PATH]; +CMPlugin g_plugin; int hLangpack = 0; MWindowList hAvatarWindowsList = nullptr; @@ -60,14 +59,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) return &pluginInfo; } -///////////////////////////////////////////////////////////////////////////////////////// - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - hInst = hinstDLL; - return TRUE; -} - ///////////////////////////////////////////////////////////////////////////////////////// // services @@ -296,7 +287,7 @@ extern "C" __declspec(dllexport) int Load(void) // Is first run? if (db_get_b(NULL, MODULE_NAME, "FirstRun", 1)) { // Show dialog - int ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FIRST_RUN), nullptr, FirstRunDlgProc, 0); + int ret = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FIRST_RUN), nullptr, FirstRunDlgProc, 0); if (ret == 0) return -1; diff --git a/plugins/AvatarHistory/src/icolib.cpp b/plugins/AvatarHistory/src/icolib.cpp index 38ce5a44a7..665cb0d867 100644 --- a/plugins/AvatarHistory/src/icolib.cpp +++ b/plugins/AvatarHistory/src/icolib.cpp @@ -38,7 +38,7 @@ int IcoLibIconsChanged(WPARAM, LPARAM) void SetupIcoLib() { iconList[0].hIcolib = Skin_GetIconHandle(SKINICON_OTHER_HISTORY); - Icon_Register(hInst, LPGEN("Avatar history"), iconList + 1, _countof(iconList) - 1); + Icon_Register(g_plugin.getInst(), LPGEN("Avatar history"), iconList + 1, _countof(iconList) - 1); IcoLibUpdateMenus(); } diff --git a/plugins/AvatarHistory/src/options.cpp b/plugins/AvatarHistory/src/options.cpp index 7987f862a4..b0272797b6 100644 --- a/plugins/AvatarHistory/src/options.cpp +++ b/plugins/AvatarHistory/src/options.cpp @@ -147,7 +147,7 @@ static INT_PTR CALLBACK PopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA int OptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = hInst; + odp.hInstance = g_plugin.getInst(); odp.szGroup.w = LPGENW("History"); // group to put your item under odp.szTitle.w = LPGENW("Avatar"); // name of the item odp.pfnDlgProc = OptionsDlgProc; diff --git a/plugins/AvatarHistory/src/popup.cpp b/plugins/AvatarHistory/src/popup.cpp index 2b5dfd3165..16e52cb53b 100644 --- a/plugins/AvatarHistory/src/popup.cpp +++ b/plugins/AvatarHistory/src/popup.cpp @@ -43,7 +43,7 @@ void InitPopups() // window needed for popup commands hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW, L"static", _A2W(MODULE_NAME) L"_PopupWindow", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, - nullptr, hInst, nullptr); + nullptr, g_plugin.getInst(), nullptr); SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LONG_PTR)PopupWndProc); } diff --git a/plugins/AvatarHistory/src/stdafx.h b/plugins/AvatarHistory/src/stdafx.h index 28b882b8d9..d865398e6e 100644 --- a/plugins/AvatarHistory/src/stdafx.h +++ b/plugins/AvatarHistory/src/stdafx.h @@ -6,8 +6,6 @@ #include #include -#define __NO_CMPLUGIN_NEEDED - #include #include #include @@ -35,7 +33,6 @@ #include "popup.h" // Globals -extern HINSTANCE hInst; extern HGENMENU hMenu; extern DWORD mirVer; extern MWindowList hAvatarWindowsList; @@ -45,6 +42,13 @@ extern wchar_t basedir[]; #define MODULE_NAME "AvatarHistory" +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN(MODULE_NAME) + {} +}; + #define AVH_DEF_POPUPFG 0 #define AVH_DEF_POPUPBG 0x2DB6FF #define AVH_DEF_AVPOPUPS 0 -- cgit v1.2.3