From ba1083b4da33ca44a5ae7d90eabbe3d6d340a81e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 17 May 2018 16:47:04 +0300 Subject: XSoundNotify, YAPP, YaRelay, ZeroSwitch, ZeroNotify -> CMPlugin --- plugins/ZeroSwitch/src/ZeroSwitch.cpp | 37 ++++++++++++++++++++++------------- plugins/ZeroSwitch/src/stdafx.h | 1 - 2 files changed, 23 insertions(+), 15 deletions(-) (limited to 'plugins/ZeroSwitch/src') diff --git a/plugins/ZeroSwitch/src/ZeroSwitch.cpp b/plugins/ZeroSwitch/src/ZeroSwitch.cpp index 1230b92a2e..1c26de1e98 100644 --- a/plugins/ZeroSwitch/src/ZeroSwitch.cpp +++ b/plugins/ZeroSwitch/src/ZeroSwitch.cpp @@ -3,12 +3,21 @@ #include "stdafx.h" -HINSTANCE hInst; +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN(nullptr) + {} +} +g_plugin; + HHOOK hHook; HWND hDummyWnd = nullptr, hHelperWnd = nullptr, hMirandaWnd = nullptr; int hLangpack; CLIST_INTERFACE *pcli; +///////////////////////////////////////////////////////////////////////////////////////// + PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -22,17 +31,13 @@ PLUGININFOEX pluginInfo = { { 0x3f1657b1, 0x69cb, 0x4992, { 0x9c, 0xfc, 0x22, 0x6c, 0x80, 0x8a, 0x52, 0x2 } } }; -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - hInst = hinstDLL; - return TRUE; -} - extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { return &pluginInfo; } +///////////////////////////////////////////////////////////////////////////////////////// + LRESULT CALLBACK HelperProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) @@ -73,7 +78,7 @@ void CreateHelperWnd() wcex.lpfnWndProc = HelperProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; - wcex.hInstance = hInst; + wcex.hInstance = g_plugin.getInst(); wcex.hIcon = Skin_LoadIcon(SKINICON_OTHER_MIRANDA, true); wcex.hCursor = nullptr; wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); @@ -84,14 +89,14 @@ void CreateHelperWnd() if (NULL == RegisterClassEx(&wcex)) return; // wtf - hDummyWnd = CreateWindow(L"ZeroSwitchHlp", L"", WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, hInst, nullptr); + hDummyWnd = CreateWindow(L"ZeroSwitchHlp", L"", WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, g_plugin.getInst(), nullptr); if (!hDummyWnd) - UnregisterClass(L"ZeroSwitchHlp", hInst); - hHelperWnd = CreateWindow(L"ZeroSwitchHlp", L"Miranda NG", WS_OVERLAPPEDWINDOW | WS_VISIBLE, -100, -100, 90, 90, hDummyWnd, nullptr, hInst, nullptr); + UnregisterClass(L"ZeroSwitchHlp", g_plugin.getInst()); + hHelperWnd = CreateWindow(L"ZeroSwitchHlp", L"Miranda NG", WS_OVERLAPPEDWINDOW | WS_VISIBLE, -100, -100, 90, 90, hDummyWnd, nullptr, g_plugin.getInst(), nullptr); if (!hHelperWnd) { DestroyWindow(hDummyWnd); - UnregisterClass(L"ZeroSwitchHlp", hInst); + UnregisterClass(L"ZeroSwitchHlp", g_plugin.getInst()); } } @@ -101,7 +106,7 @@ void DestroyHelperWnd() { DestroyWindow(hHelperWnd); DestroyWindow(hDummyWnd); - UnregisterClass(L"ZeroSwitchHlp", hInst); + UnregisterClass(L"ZeroSwitchHlp", g_plugin.getInst()); } } @@ -129,6 +134,8 @@ LRESULT CALLBACK CallWndRetProc(int nCode, WPARAM wParam, LPARAM lParam) return CallNextHookEx(nullptr, nCode, wParam, lParam); // Pass the message to other hooks in chain } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); @@ -146,10 +153,12 @@ extern "C" int __declspec(dllexport) Load(void) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" int __declspec(dllexport) Unload(void) { if (hHook) UnhookWindowsHookEx(hHook); DestroyHelperWnd(); return 0; -} \ No newline at end of file +} diff --git a/plugins/ZeroSwitch/src/stdafx.h b/plugins/ZeroSwitch/src/stdafx.h index 8b91cd0a06..ac729e6640 100644 --- a/plugins/ZeroSwitch/src/stdafx.h +++ b/plugins/ZeroSwitch/src/stdafx.h @@ -9,7 +9,6 @@ // Windows Header Files: #include -#define __NO_CMPLUGIN_NEEDED #include #include #include -- cgit v1.2.3