diff options
Diffstat (limited to 'plugins/ZeroSwitch')
-rw-r--r-- | plugins/ZeroSwitch/src/ZeroSwitch.cpp | 37 | ||||
-rw-r--r-- | plugins/ZeroSwitch/src/stdafx.h | 1 |
2 files changed, 23 insertions, 15 deletions
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>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(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 <windows.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clistint.h>
#include <m_skin.h>
|