diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-17 16:47:04 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-17 16:47:04 +0300 |
commit | ba1083b4da33ca44a5ae7d90eabbe3d6d340a81e (patch) | |
tree | ff215cbcb7d606f9898dbb0f038e850540f52e75 /plugins/ZeroSwitch/src/ZeroSwitch.cpp | |
parent | 3c641c02b973483e86b9562088719396bbdbe412 (diff) |
XSoundNotify, YAPP, YaRelay, ZeroSwitch, ZeroNotify -> CMPlugin
Diffstat (limited to 'plugins/ZeroSwitch/src/ZeroSwitch.cpp')
-rw-r--r-- | plugins/ZeroSwitch/src/ZeroSwitch.cpp | 37 |
1 files changed, 23 insertions, 14 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 +}
|