summaryrefslogtreecommitdiff
path: root/plugins/TooltipNotify
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-17 17:49:56 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-17 17:49:56 +0300
commit4c4735a232c680e60a85d0f85e2cb392e012c6e0 (patch)
tree104af4cac8863f6f428a23a579167ab0a5b01d6a /plugins/TooltipNotify
parentbce8bc74daf1c5f510404c8bdf956b41fb1c10fc (diff)
Toaster, TooltipNotify, TrafficCounter, UInfoEx, UserGuide, Variables -> CMPlugin
Diffstat (limited to 'plugins/TooltipNotify')
-rw-r--r--plugins/TooltipNotify/src/Tooltip.cpp6
-rw-r--r--plugins/TooltipNotify/src/TooltipNotify.cpp17
-rw-r--r--plugins/TooltipNotify/src/main.cpp99
-rw-r--r--plugins/TooltipNotify/src/stdafx.h10
4 files changed, 52 insertions, 80 deletions
diff --git a/plugins/TooltipNotify/src/Tooltip.cpp b/plugins/TooltipNotify/src/Tooltip.cpp
index 7552ec858d..014802da07 100644
--- a/plugins/TooltipNotify/src/Tooltip.cpp
+++ b/plugins/TooltipNotify/src/Tooltip.cpp
@@ -20,7 +20,7 @@ CTooltip::CTooltip(CTooltipNotify *pTooltipNotify)
m_hWnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, s_szTooltipClass, nullptr,
WS_POPUP|WS_BORDER, 100, 100, 50, 50, nullptr, nullptr,
- g_hInstDLL, nullptr);
+ g_plugin.getInst(), nullptr);
SetWindowLongPtr(m_hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
}
@@ -40,14 +40,14 @@ CTooltip::~CTooltip()
wcexWndClass.cbSize = sizeof(WNDCLASSEX);
wcexWndClass.style = CS_SAVEBITS;
wcexWndClass.lpfnWndProc = (WNDPROC)CTooltip::WindowProcWrapper;
- wcexWndClass.hInstance = g_hInstDLL;
+ wcexWndClass.hInstance = g_plugin.getInst();
wcexWndClass.lpszClassName = s_szTooltipClass;
RegisterClassEx(&wcexWndClass);
}
/*static*/ void CTooltip::Deinitialize()
{
- UnregisterClass(s_szTooltipClass, g_hInstDLL);
+ UnregisterClass(s_szTooltipClass, g_plugin.getInst());
}
LRESULT CALLBACK CTooltip::WindowProcWrapper(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
diff --git a/plugins/TooltipNotify/src/TooltipNotify.cpp b/plugins/TooltipNotify/src/TooltipNotify.cpp
index e513d20e7d..5b0e55ae4b 100644
--- a/plugins/TooltipNotify/src/TooltipNotify.cpp
+++ b/plugins/TooltipNotify/src/TooltipNotify.cpp
@@ -53,7 +53,7 @@ const char *CTooltipNotify::s_szModuleNameOld = "ttntfmod";
//////////////////////////////////////////////////////////////////////
CTooltipNotify::CTooltipNotify() :
-m_bNt50(IsNt50())
+ m_bNt50(IsNt50())
{
if (s_pInstance != nullptr)
throw EAlreadyExists();
@@ -257,7 +257,7 @@ int CTooltipNotify::InitializeOptions(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = g_hInstDLL;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.szTitle.a = LPGEN("Tooltip Notify");
odp.szGroup.a = LPGEN("Popups");
@@ -342,14 +342,9 @@ void CTooltipNotify::EndNotifyAll()
CTooltipNotify::MapTimerIdProtoIter CTooltipNotify::FindProtoByTimer(UINT idTimer)
{
- for (
- MapTimerIdProtoIter iter = m_mapTimerIdProto.begin();
- iter != m_mapTimerIdProto.end();
- ++iter) {
- if (iter->timerId == idTimer) {
+ for (MapTimerIdProtoIter iter = m_mapTimerIdProto.begin(); iter != m_mapTimerIdProto.end(); ++iter)
+ if (iter->timerId == idTimer)
return iter;
- }
- }
return m_mapTimerIdProto.end();
}
@@ -587,11 +582,11 @@ BOOL CTooltipNotify::OptionsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
}
case IDC_SEL_PROTO:
- DialogBox(g_hInstDLL, MAKEINTRESOURCE(IDD_PROTOS), hDlg, CTooltipNotify::ProtosDlgProcWrapper);
+ DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_PROTOS), hDlg, CTooltipNotify::ProtosDlgProcWrapper);
break;
case IDC_IGNORE:
- DialogBox(g_hInstDLL, MAKEINTRESOURCE(IDD_CONTACTS), hDlg, CTooltipNotify::ContactsDlgProcWrapper);
+ DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTACTS), hDlg, CTooltipNotify::ContactsDlgProcWrapper);
break;
default:
diff --git a/plugins/TooltipNotify/src/main.cpp b/plugins/TooltipNotify/src/main.cpp
index 9b84a68cb5..001fa83d7b 100644
--- a/plugins/TooltipNotify/src/main.cpp
+++ b/plugins/TooltipNotify/src/main.cpp
@@ -4,34 +4,19 @@
#include "stdafx.h"
-static int InitializeOptions(WPARAM wParam,LPARAM lParam);
-static int ModulesLoaded(WPARAM wParam,LPARAM lParam);
-static int ContactSettingChanged(WPARAM wParam,LPARAM lParam);
-static int ProtoAck(WPARAM,LPARAM);
-static int ProtoContactIsTyping(WPARAM wParam,LPARAM lParam);
-
static HANDLE g_hContactSettingChanged = nullptr;
static HANDLE g_hOptionsInitialize = nullptr;
static HANDLE g_hModulesLoaded = nullptr;
static HANDLE g_hProtoAck = nullptr;
static HANDLE g_hProtoContactIsTyping = nullptr;
-HINSTANCE g_hInstDLL = nullptr;
-
// Main global object
static CTooltipNotify *g_pTooltipNotify = nullptr;
int hLangpack;
CLIST_INTERFACE *pcli;
+CMPlugin g_plugin;
-//================================================================================
-// plugin init/deinit routines
-//================================================================================
-
-BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD, LPVOID)
-{
- g_hInstDLL = hInstDLL;
- return TRUE;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
static PLUGININFOEX sPluginInfo =
{
@@ -52,72 +37,60 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
return &sPluginInfo;
}
-extern "C" int __declspec(dllexport) Load(void)
-{
- mir_getLP(&sPluginInfo);
- pcli = Clist_GetInterface();
+/////////////////////////////////////////////////////////////////////////////////////////
- g_pTooltipNotify = new CTooltipNotify();
- assert(g_pTooltipNotify!=nullptr);
-
- g_hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- return 0;
+static int ProtoContactIsTyping(WPARAM wParam, LPARAM lParam)
+{
+ return CTooltipNotify::GetObjInstance()->ProtoContactIsTyping(wParam, lParam);
}
-extern "C" int __declspec(dllexport) Unload(void)
+static int ProtoAck(WPARAM wParam, LPARAM lParam)
{
- if (g_hContactSettingChanged) UnhookEvent(g_hContactSettingChanged);
- if (g_hProtoContactIsTyping) UnhookEvent(g_hProtoContactIsTyping);
- if (g_hProtoAck) UnhookEvent(g_hProtoAck);
- if (g_hOptionsInitialize) UnhookEvent(g_hOptionsInitialize);
- if (g_hModulesLoaded) UnhookEvent(g_hModulesLoaded);
- delete g_pTooltipNotify;
-
- return 0;
+ return CTooltipNotify::GetObjInstance()->ProtoAck(wParam, lParam);
}
+static int ContactSettingChanged(WPARAM wParam, LPARAM lParam)
+{
+ return CTooltipNotify::GetObjInstance()->ContactSettingChanged(wParam, lParam);
+}
+static int InitializeOptions(WPARAM wParam, LPARAM lParam)
+{
+ return CTooltipNotify::GetObjInstance()->InitializeOptions(wParam, lParam);
+}
-//================================================================================
-//================================================================================
-//================================================================================
-
-
-int ModulesLoaded(WPARAM wParam, LPARAM lParam)
+static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
g_hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
g_hProtoAck = HookEvent(ME_PROTO_ACK, ProtoAck);
g_hProtoContactIsTyping = HookEvent(ME_PROTO_CONTACTISTYPING, ProtoContactIsTyping);
- g_hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, InitializeOptions);
+ g_hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, InitializeOptions);
return CTooltipNotify::GetObjInstance()->ModulesLoaded(wParam, lParam);
}
-
-int ProtoContactIsTyping(WPARAM wParam, LPARAM lParam)
-{
- return CTooltipNotify::GetObjInstance()->ProtoContactIsTyping(wParam, lParam);
-}
-
-
-int ProtoAck(WPARAM wParam, LPARAM lParam)
+extern "C" int __declspec(dllexport) Load(void)
{
- return CTooltipNotify::GetObjInstance()->ProtoAck(wParam, lParam);
-}
-
+ mir_getLP(&sPluginInfo);
+ pcli = Clist_GetInterface();
-int ContactSettingChanged(WPARAM wParam, LPARAM lParam)
-{
- return CTooltipNotify::GetObjInstance()->ContactSettingChanged(wParam, lParam);
+ g_pTooltipNotify = new CTooltipNotify();
+ assert(g_pTooltipNotify!=nullptr);
+
+ g_hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
-int InitializeOptions(WPARAM wParam, LPARAM lParam)
+extern "C" int __declspec(dllexport) Unload(void)
{
- return CTooltipNotify::GetObjInstance()->InitializeOptions(wParam, lParam);
-}
-
-
-
-
+ if (g_hContactSettingChanged) UnhookEvent(g_hContactSettingChanged);
+ if (g_hProtoContactIsTyping) UnhookEvent(g_hProtoContactIsTyping);
+ if (g_hProtoAck) UnhookEvent(g_hProtoAck);
+ if (g_hOptionsInitialize) UnhookEvent(g_hOptionsInitialize);
+ if (g_hModulesLoaded) UnhookEvent(g_hModulesLoaded);
+ delete g_pTooltipNotify;
+ return 0;
+}
diff --git a/plugins/TooltipNotify/src/stdafx.h b/plugins/TooltipNotify/src/stdafx.h
index d8b6960fde..bfe460cfcd 100644
--- a/plugins/TooltipNotify/src/stdafx.h
+++ b/plugins/TooltipNotify/src/stdafx.h
@@ -13,7 +13,6 @@
#include <algorithm>
#include <vector>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clistint.h>
#include <m_skin.h>
@@ -28,6 +27,13 @@
#define MODULENAME "TooltipNotify"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
+
#include "version.h"
#include "TooltipNotify.h"
#include "DbHelpers.h"
@@ -35,5 +41,3 @@
#include "Settings.h"
#include "resource.h"
#include "Utils.h"
-
-extern HINSTANCE g_hInstDLL; \ No newline at end of file