From b172c4bbc75cdad0e8ccd22292aa671ba43cac45 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Apr 2018 18:14:33 +0300 Subject: PLUGIN<> to half-automatically calculate the dll's g_hInstance and pass it inside --- plugins/Non-IM Contact/src/dialog.cpp | 16 ++++++++-------- plugins/Non-IM Contact/src/main.cpp | 14 ++++++++------ plugins/Non-IM Contact/src/stdafx.h | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) (limited to 'plugins/Non-IM Contact/src') diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp index c3c550eb59..5923e9794f 100644 --- a/plugins/Non-IM Contact/src/dialog.cpp +++ b/plugins/Non-IM Contact/src/dialog.cpp @@ -123,7 +123,7 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_HELPMSG: - CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_HELP), nullptr, HelpWindowDlgProc); + CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_HELP), nullptr, HelpWindowDlgProc); break; case IDCANCEL: @@ -205,13 +205,13 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) INT_PTR testStringReplacer(WPARAM, LPARAM) { - CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TEST_LINE), nullptr, TestWindowDlgProc); + CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_TEST_LINE), nullptr, TestWindowDlgProc); return 0; } INT_PTR LoadFilesDlg(WPARAM, LPARAM) { - CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_ADD_FILE), nullptr, DlgProcFiles); + CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_ADD_FILE), nullptr, DlgProcFiles); return 0; } @@ -241,7 +241,7 @@ void DoPropertySheet(MCONTACT hContact) /* contact info */ psp[0].dwSize = sizeof(PROPSHEETPAGE); psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE; - psp[0].hInstance = g_hInst; + psp[0].hInstance = g_hInstance; psp[0].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_INFO); psp[0].pszIcon = nullptr; psp[0].pfnDlgProc = DlgProcContactInfo; @@ -252,7 +252,7 @@ void DoPropertySheet(MCONTACT hContact) /* other settings */ psp[1].dwSize = sizeof(PROPSHEETPAGE); psp[1].dwFlags = PSP_USEICONID | PSP_USETITLE; - psp[1].hInstance = g_hInst; + psp[1].hInstance = g_hInstance; psp[1].pszTemplate = MAKEINTRESOURCEA(IDD_OTHER_STUFF); psp[1].pszIcon = nullptr; psp[1].pfnDlgProc = DlgProcOtherStuff; @@ -263,7 +263,7 @@ void DoPropertySheet(MCONTACT hContact) /* copy contact */ psp[2].dwSize = sizeof(PROPSHEETPAGE); psp[2].dwFlags = PSP_USEICONID | PSP_USETITLE; - psp[2].hInstance = g_hInst; + psp[2].hInstance = g_hInstance; psp[2].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COPYEXPORT); psp[2].pszIcon = nullptr; psp[2].pfnDlgProc = DlgProcCopy; @@ -274,7 +274,7 @@ void DoPropertySheet(MCONTACT hContact) /* files */ psp[3].dwSize = sizeof(PROPSHEETPAGE); psp[3].dwFlags = PSP_USEICONID | PSP_USETITLE; - psp[3].hInstance = g_hInst; + psp[3].hInstance = g_hInstance; psp[3].pszTemplate = MAKEINTRESOURCEA(IDD_ADD_FILE); psp[3].pszIcon = nullptr; psp[3].pfnDlgProc = DlgProcFiles; @@ -285,7 +285,7 @@ void DoPropertySheet(MCONTACT hContact) /* propery sheet header.. dont touch !!!! */ PROPSHEETHEADERA psh = { sizeof(psh) }; psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_USECALLBACK; - psh.hInstance = g_hInst; + psh.hInstance = g_hInstance; psh.pszIcon = MAKEINTRESOURCEA(IDI_MAIN); if (!db_get_static(hContact, MODNAME, "Nick", nick, _countof(nick))) { char title[256]; diff --git a/plugins/Non-IM Contact/src/main.cpp b/plugins/Non-IM Contact/src/main.cpp index fd7de1059d..36e2d33361 100644 --- a/plugins/Non-IM Contact/src/main.cpp +++ b/plugins/Non-IM Contact/src/main.cpp @@ -7,7 +7,7 @@ #include "Version.h" CLIST_INTERFACE *pcli; -HINSTANCE g_hInst; +HINSTANCE g_hInstance; int hLangpack; PLUGININFOEX pluginInfoEx = { @@ -63,7 +63,7 @@ int LCStatus = ID_STATUS_OFFLINE; int NimcOptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = g_hInst; + odp.hInstance = g_hInstance; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); odp.szGroup.a = LPGEN("Plugins"); odp.szTitle.a = LPGEN("Non-IM Contacts"); @@ -94,7 +94,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC // BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID) { - g_hInst = hinst; + g_hInstance = hinst; return TRUE; } @@ -121,7 +121,7 @@ extern "C" __declspec(dllexport) int Load() mir_getLP(&pluginInfoEx); pcli = Clist_GetInterface(); - Icon_Register(g_hInst, LPGEN("Non-IM Contact"), icoList, _countof(icoList)); + Icon_Register(g_hInstance, LPGEN("Non-IM Contact"), icoList, _countof(icoList)); HookEvent(ME_CLIST_DOUBLECLICKED, (MIRANDAHOOK)doubleClick); HookEvent(ME_OPT_INITIALISE, NimcOptInit); @@ -204,12 +204,14 @@ extern "C" __declspec(dllexport) int Unload(void) ///////////////////////////////////////////////////////////////////////////////////////// -struct CMPlugin : public CMPluginBase +struct CMPlugin : public PLUGIN { CMPlugin() : - CMPluginBase(MODNAME) + PLUGIN(MODNAME) { RegisterProtocol(PROTOTYPE_VIRTUAL); } } g_plugin; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; diff --git a/plugins/Non-IM Contact/src/stdafx.h b/plugins/Non-IM Contact/src/stdafx.h index ef713be562..857bb66680 100644 --- a/plugins/Non-IM Contact/src/stdafx.h +++ b/plugins/Non-IM Contact/src/stdafx.h @@ -69,7 +69,7 @@ struct DLGTEMPLATEEX // Defines //======================================================= //General -extern HINSTANCE g_hInst; +extern HINSTANCE g_hInstance; extern int LCStatus; extern IconItem icoList[]; -- cgit v1.2.3