diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-17 18:23:34 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-17 18:23:34 +0300 |
commit | 2aa59179945482dee30935c991f9317dfbf31946 (patch) | |
tree | 49fc2b77d68b636c7842a1af462af59c94ff6da5 /plugins/TipperYM | |
parent | 4c4735a232c680e60a85d0f85e2cb392e012c6e0 (diff) |
Tipper, StopSpamMod, StopSpam, StatusManager, StatusChange, StartupSilence, StartPosition, SplashScreen, SpellChecker, Spamotron => CMPlugin
Diffstat (limited to 'plugins/TipperYM')
-rw-r--r-- | plugins/TipperYM/src/message_pump.cpp | 6 | ||||
-rw-r--r-- | plugins/TipperYM/src/options.cpp | 16 | ||||
-rw-r--r-- | plugins/TipperYM/src/stdafx.h | 8 | ||||
-rw-r--r-- | plugins/TipperYM/src/tipper.cpp | 32 |
4 files changed, 33 insertions, 29 deletions
diff --git a/plugins/TipperYM/src/message_pump.cpp b/plugins/TipperYM/src/message_pump.cpp index ffc5237068..5eb1182f15 100644 --- a/plugins/TipperYM/src/message_pump.cpp +++ b/plugins/TipperYM/src/message_pump.cpp @@ -124,7 +124,7 @@ unsigned int CALLBACK MessagePumpThread(void*) if (!NeedWaitForContent(clcitex)) {
if (hwndTip)
MyDestroyWindow(hwndTip);
- hwndTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, nullptr, WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, hInst, (LPVOID)clcitex);
+ hwndTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, nullptr, WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, g_plugin.getInst(), (LPVOID)clcitex);
if (clcitex) {
mir_free(clcitex);
@@ -214,7 +214,7 @@ void InitMessagePump() WNDCLASSEX wcl = {0};
wcl.cbSize = sizeof(wcl);
wcl.lpfnWndProc = PopupWindowProc;
- wcl.hInstance = hInst;
+ wcl.hInstance = g_plugin.getInst();
wcl.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszClassName = POP_WIN_CLASS;
@@ -230,7 +230,7 @@ void InitMessagePump() void DeinitMessagePump()
{
PostMPMessage(WM_QUIT, 0, 0);
- UnregisterClass(POP_WIN_CLASS, hInst);
+ UnregisterClass(POP_WIN_CLASS, g_plugin.getInst());
FreeLibrary(hDwmapiDll);
}
diff --git a/plugins/TipperYM/src/options.cpp b/plugins/TipperYM/src/options.cpp index 67de4e4143..3e920bb3d4 100644 --- a/plugins/TipperYM/src/options.cpp +++ b/plugins/TipperYM/src/options.cpp @@ -847,7 +847,7 @@ INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0);
if (sel != CB_ERR) {
DSListNode *ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0);
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) {
+ if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) {
SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0);
sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName);
@@ -867,7 +867,7 @@ INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA memset(di_value, 0, sizeof(DIListNode));
di_value->di.bIsVisible = true;
- int result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di);
+ int result = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di);
if (result == IDOK || (result >= IDPRESETITEM && result < (IDPRESETITEM + 100))) {
TVINSERTSTRUCT tvi = {};
tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE;
@@ -1020,7 +1020,7 @@ INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if (item.hItem) {
if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) {
DIListNode *di_value = (DIListNode *)item.lParam;
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di) == IDOK) {
+ if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di) == IDOK) {
item.mask = TVIF_TEXT;
SetTreeItemText(di_value, &item.pszText);
TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item);
@@ -1036,7 +1036,7 @@ INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA {
DSListNode *ds_value = (DSListNode *)mir_alloc(sizeof(DSListNode));
memset(ds_value, 0, sizeof(DSListNode));
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) {
+ if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) {
int index = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName);
SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, index, (LPARAM)ds_value);
SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, index, 0);
@@ -1067,7 +1067,7 @@ INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0);
if (sel != LB_ERR) {
DSListNode *ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0);
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) {
+ if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&ds_value->ds) == IDOK) {
SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0);
sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.swzName);
@@ -1144,7 +1144,7 @@ INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if (item.hItem) {
if (TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item)) {
DIListNode *di_value = (DIListNode *)item.lParam;
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di) == IDOK) {
+ if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&di_value->di) == IDOK) {
item.mask = TVIF_TEXT;
SetTreeItemText(di_value, &item.pszText);
TreeView_SetItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &item);
@@ -1965,7 +1965,7 @@ INT_PTR CALLBACK DlgProcOptsTraytip(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break;
case IDC_BTN_FAVCONTACTS:
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_FAVCONTACTS), nullptr, DlgProcFavouriteContacts);
+ CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FAVCONTACTS), nullptr, DlgProcFavouriteContacts);
break;
}
@@ -2083,7 +2083,7 @@ int OptInit(WPARAM wParam, LPARAM) OPTIONSDIALOGPAGE odp = { 0 };
odp.flags = ODPF_BOLDGROUPS;
odp.position = -790000000;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_APPEARANCE);
odp.szTab.a = LPGEN("Appearance");
diff --git a/plugins/TipperYM/src/stdafx.h b/plugins/TipperYM/src/stdafx.h index fe059869bb..d338ff81cc 100644 --- a/plugins/TipperYM/src/stdafx.h +++ b/plugins/TipperYM/src/stdafx.h @@ -28,7 +28,6 @@ Boston, MA 02111-1307, USA. #include <windowsx.h>
#include <malloc.h>
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_avatars.h>
@@ -74,7 +73,12 @@ Boston, MA 02111-1307, USA. #define MODULE_ITEMS "Tipper_Items"
#define DEFAULT_SKIN_FOLDER L"Skins\\Tipper"
-extern HMODULE hInst;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE)
+ {}
+};
extern HFONT hFontTitle, hFontLabels, hFontValues, hFontTrayTitle;
extern COLORREF colTitle, colLabels, colBg, colValues;
diff --git a/plugins/TipperYM/src/tipper.cpp b/plugins/TipperYM/src/tipper.cpp index a28b8a7798..216b4e2af6 100644 --- a/plugins/TipperYM/src/tipper.cpp +++ b/plugins/TipperYM/src/tipper.cpp @@ -20,7 +20,9 @@ Boston, MA 02111-1307, USA. #include "stdafx.h"
-HMODULE hInst;
+int hLangpack;
+CMPlugin g_plugin;
+CLIST_INTERFACE *pcli;
FontIDW fontTitle, fontLabels, fontValues, fontTrayTitle;
ColourIDW colourBg, colourBorder, colourAvatarBorder, colourDivider, colourSidebar;
@@ -34,8 +36,7 @@ HANDLE hReloadFonts = nullptr; HANDLE hFolderChanged, hSkinFolder;
wchar_t SKIN_FOLDER[256];
-CLIST_INTERFACE *pcli;
-int hLangpack;
+/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfoEx =
{
@@ -51,17 +52,13 @@ PLUGININFOEX pluginInfoEx = {0x8392df1d, 0x9090, 0x4f8e, {0x9d, 0xf6, 0x2f, 0xe0, 0x58, 0xed, 0xd8, 0x00}}
};
-bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
int ReloadFont(WPARAM, LPARAM)
{
LOGFONT logFont;
@@ -86,12 +83,11 @@ int ReloadFont(WPARAM, LPARAM) opt.colAvatarBorder = Colour_GetW(colourAvatarBorder);
opt.colSidebar = Colour_GetW(colourSidebar);
opt.colDivider = Colour_GetW(colourDivider);
-
return 0;
}
// hack to hide tip when clist hides from timeout
-int SettingChanged(WPARAM, LPARAM lParam)
+static int SettingChanged(WPARAM, LPARAM lParam)
{
DBCONTACTWRITESETTING *dcws = (DBCONTACTWRITESETTING *)lParam;
if (strcmp(dcws->szModule, "CList") != 0 || strcmp(dcws->szSetting, "State") != 0)
@@ -105,7 +101,7 @@ int SettingChanged(WPARAM, LPARAM lParam) }
// needed for msg_count_xxx substitutions
-int EventDeleted(WPARAM wParam, LPARAM lParam)
+static int EventDeleted(WPARAM wParam, LPARAM lParam)
{
DBEVENTINFO dbei = {};
if (!db_event_get(lParam, &dbei))
@@ -115,13 +111,13 @@ int EventDeleted(WPARAM wParam, LPARAM lParam) return 0;
}
-int ReloadSkinFolder(WPARAM, LPARAM)
+static int ReloadSkinFolder(WPARAM, LPARAM)
{
FoldersGetCustomPathT(hSkinFolder, SKIN_FOLDER, _countof(SKIN_FOLDER), DEFAULT_SKIN_FOLDER);
return 0;
}
-void InitFonts()
+static void InitFonts()
{
colourBg.cbSize = sizeof(ColourIDW);
mir_wstrcpy(colourBg.group, LPGENW("Tooltips"));
@@ -240,7 +236,7 @@ void InitFonts() hReloadFonts = HookEvent(ME_FONT_RELOAD, ReloadFont);
}
-int ModulesLoaded(WPARAM, LPARAM)
+static int ModulesLoaded(WPARAM, LPARAM)
{
InitFonts();
@@ -307,6 +303,8 @@ static INT_PTR ReloadSkin(WPARAM wParam, LPARAM lParam) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
IconItem iconList[] =
{
{ LPGEN("Copy item"), "copy_item", IDI_ITEM },
@@ -325,7 +323,7 @@ extern "C" int __declspec(dllexport) Load(void) iCodePage = Langpack_GetDefaultCodePage();
- Icon_Register(hInst, MODULE, iconList, _countof(iconList), MODULE);
+ Icon_Register(g_plugin.getInst(), MODULE, iconList, _countof(iconList), MODULE);
InitTranslations();
InitMessagePump();
@@ -346,6 +344,8 @@ extern "C" int __declspec(dllexport) Load(void) return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload()
{
UnhookEvent(hSettingChangedEvent);
|