From 9cf1444eb7888f2d942d220f938aa893396a8a1b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Apr 2018 20:51:18 +0300 Subject: g_hInstance incapulated into PLUGIN<>, no need in the separate variable --- plugins/YAMN/src/browser/badconnect.cpp | 2 +- plugins/YAMN/src/browser/mailbrowser.cpp | 4 ++-- plugins/YAMN/src/main.cpp | 24 +++++++----------------- plugins/YAMN/src/proto/pop3/pop3opt.cpp | 4 ++-- plugins/YAMN/src/stdafx.h | 13 +++++++++++-- 5 files changed, 23 insertions(+), 24 deletions(-) (limited to 'plugins/YAMN/src') diff --git a/plugins/YAMN/src/browser/badconnect.cpp b/plugins/YAMN/src/browser/badconnect.cpp index 7b84b15c44..894b0bace0 100644 --- a/plugins/YAMN/src/browser/badconnect.cpp +++ b/plugins/YAMN/src/browser/badconnect.cpp @@ -220,7 +220,7 @@ void __cdecl BadConnection(void *Param) SetEvent(MyParam.ThreadRunningEV); __try { - hBadConnect = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_DLGBADCONNECT), nullptr, DlgProcYAMNBadConnection, (LPARAM)&MyParam); + hBadConnect = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DLGBADCONNECT), nullptr, DlgProcYAMNBadConnection, (LPARAM)&MyParam); Window_SetIcon_IcoLib(hBadConnect, g_GetIconHandle(3)); #ifdef DEBUG_SYNCHRO diff --git a/plugins/YAMN/src/browser/mailbrowser.cpp b/plugins/YAMN/src/browser/mailbrowser.cpp index 7ecab8374d..60ca3431e3 100644 --- a/plugins/YAMN/src/browser/mailbrowser.cpp +++ b/plugins/YAMN/src/browser/mailbrowser.cpp @@ -1604,7 +1604,7 @@ void __cdecl ShowEmailThread(void *Param) } else { CREADTEVIEWMESSAGEWINDOW: - MyParam.mail->MsgWindow = CreateDialogParamW(g_hInstance, MAKEINTRESOURCEW(IDD_DLGSHOWMESSAGE), nullptr, DlgProcYAMNShowMessage, (LPARAM)&MyParam); + MyParam.mail->MsgWindow = CreateDialogParamW(g_plugin.getInst(), MAKEINTRESOURCEW(IDD_DLGSHOWMESSAGE), nullptr, DlgProcYAMNShowMessage, (LPARAM)&MyParam); WindowList_Add(YAMNVar.MessageWnds, MyParam.mail->MsgWindow); MSG msg; while (GetMessage(&msg, nullptr, 0, 0)) { @@ -2318,7 +2318,7 @@ void __cdecl MailBrowser(void *Param) WndFound = TRUE; if ((hMailBrowser == nullptr) && ((MyParam.nflags & YAMN_ACC_MSG) || (MyParam.nflags & YAMN_ACC_ICO) || (MyParam.nnflags & YAMN_ACC_MSG))) { - hMailBrowser = CreateDialogParamW(g_hInstance, MAKEINTRESOURCEW(IDD_DLGVIEWMESSAGES), nullptr, DlgProcYAMNMailBrowser, (LPARAM)&MyParam); + hMailBrowser = CreateDialogParamW(g_plugin.getInst(), MAKEINTRESOURCEW(IDD_DLGVIEWMESSAGES), nullptr, DlgProcYAMNMailBrowser, (LPARAM)&MyParam); Window_SetIcon_IcoLib(hMailBrowser, g_GetIconHandle(2)); MoveWindow(hMailBrowser, PosX, PosY, SizeX, SizeY, TRUE); } diff --git a/plugins/YAMN/src/main.cpp b/plugins/YAMN/src/main.cpp index 7491051500..53ff5dbf6a 100644 --- a/plugins/YAMN/src/main.cpp +++ b/plugins/YAMN/src/main.cpp @@ -23,7 +23,6 @@ int YAMN_STATUS; BOOL UninstallPlugins; HANDLE hAccountFolder; -HINSTANCE g_hInstance; HINSTANCE *hDllPlugins; static int iDllPlugins = 0; @@ -70,6 +69,12 @@ static void GetProfileDirectory(wchar_t *szPath, int cbPath) ///////////////////////////////////////////////////////////////////////////////////////// +CMPlugin g_plugin; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; + +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -163,7 +168,7 @@ static IconItem iconList[] = void LoadIcons() { - Icon_Register(g_hInstance, "YAMN", iconList, _countof(iconList)); + Icon_Register(g_plugin.getInst(), "YAMN", iconList, _countof(iconList)); } HANDLE WINAPI g_GetIconHandle(int idx) @@ -354,18 +359,3 @@ extern "C" int __declspec(dllexport) Unload(void) delete[] CodePageNamesSupp; return 0; } - -///////////////////////////////////////////////////////////////////////////////////////// - -struct CMPlugin : public PLUGIN -{ - CMPlugin() : - PLUGIN(YAMN_DBMODULE) - { - RegisterProtocol(PROTOTYPE_VIRTUAL); - SetUniqueId("Id"); - } -} - g_plugin; - -extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; diff --git a/plugins/YAMN/src/proto/pop3/pop3opt.cpp b/plugins/YAMN/src/proto/pop3/pop3opt.cpp index 405e27ab4a..f4ca57cb49 100644 --- a/plugins/YAMN/src/proto/pop3/pop3opt.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3opt.cpp @@ -154,7 +154,7 @@ INT_PTR CALLBACK DlgProcPluginOpt(HWND hDlg, UINT msg, WPARAM wParam, LPARAM) int YAMNOptInitSvc(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = g_hInstance; + odp.hInstance = g_plugin.getInst(); odp.szGroup.a = LPGEN("Network"); odp.szTitle.a = LPGEN("YAMN"); odp.flags = ODPF_BOLDGROUPS; @@ -809,7 +809,7 @@ INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP break; case IDC_BTNSTATUS: - DialogBoxParamW(g_hInstance, MAKEINTRESOURCEW(IDD_CHOOSESTATUSMODES), hDlg, DlgProcPOP3AccStatusOpt, NULL); + DialogBoxParamW(g_plugin.getInst(), MAKEINTRESOURCEW(IDD_CHOOSESTATUSMODES), hDlg, DlgProcPOP3AccStatusOpt, NULL); break; case IDC_BTNADD: diff --git a/plugins/YAMN/src/stdafx.h b/plugins/YAMN/src/stdafx.h index 55af23dff3..eb842b2efa 100644 --- a/plugins/YAMN/src/stdafx.h +++ b/plugins/YAMN/src/stdafx.h @@ -43,8 +43,17 @@ #include "proto/pop3/pop3comm.h" #include "proto/pop3/pop3opt.h" - -//From services.cpp +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN(YAMN_DBMODULE) + { + RegisterProtocol(PROTOTYPE_VIRTUAL); + SetUniqueId("Id"); + } +}; + +// From services.cpp void CreateServiceFunctions(void); void HookEvents(void); void RefreshContact(void); -- cgit v1.2.3