diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-17 21:37:53 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-17 21:37:53 +0300 |
commit | 88b04fed4966b0f1686690cb6101854afb52a5ee (patch) | |
tree | 79b4e574c0849f24907168075c8d0babfde2fde4 /plugins | |
parent | 5ebe9c34375bce857ad3160abba67d6ed2beadaf (diff) |
Db3x_mmap, Dbx_mdbx, Exchange, MyDetails, RecentContacts, TopToolBar, WebView => CMPlugin
Diffstat (limited to 'plugins')
42 files changed, 528 insertions, 548 deletions
diff --git a/plugins/ConnectionNotify/src/stdafx.h b/plugins/ConnectionNotify/src/stdafx.h index b048999086..a4719fa3b7 100644 --- a/plugins/ConnectionNotify/src/stdafx.h +++ b/plugins/ConnectionNotify/src/stdafx.h @@ -6,8 +6,6 @@ #include <iphlpapi.h>
#include <Tlhelp32.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_core.h>
#include <m_clistint.h>
@@ -50,8 +48,6 @@ struct CMPlugin : public PLUGIN<CMPlugin> };
void showMsg(wchar_t *pName,DWORD pid,wchar_t *intIp,wchar_t *extIp,int intPort,int extPort,int state);
-//int __declspec(dllexport) Load(PLUGINLINK *link);
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
static unsigned __stdcall checkthread(void *dummy);
struct CONNECTION * LoadSettingsConnections();
void saveSettingsConnections(struct CONNECTION *connHead);
diff --git a/plugins/Db3x_mmap/src/init.cpp b/plugins/Db3x_mmap/src/init.cpp index c2860ecfef..6084f09ffa 100644 --- a/plugins/Db3x_mmap/src/init.cpp +++ b/plugins/Db3x_mmap/src/init.cpp @@ -24,6 +24,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
int hLangpack;
+CMPlugin g_plugin;
+
+LIST<CDb3Mmap> g_Dbs(1, HandleKeySortT);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_DATABASE, MIID_LAST };
+
+/////////////////////////////////////////////////////////////////////////////////////////
static PLUGININFOEX pluginInfo =
{
@@ -39,9 +48,10 @@ static PLUGININFOEX pluginInfo = { 0xf7a6b27c, 0x9d9c, 0x4a42, { 0xbe, 0x86, 0xa4, 0x48, 0xae, 0x10, 0x91, 0x61 } }
};
-HINSTANCE g_hInst = nullptr;
-
-LIST<CDb3Mmap> g_Dbs(1, HandleKeySortT);
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -129,26 +139,15 @@ static DATABASELINK dblink = /////////////////////////////////////////////////////////////////////////////////////////
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfo;
-}
-
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_DATABASE, MIID_LAST };
-
extern "C" __declspec(dllexport) int Load(void)
{
RegisterDatabasePlugin(&dblink);
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
return 0;
}
-
-BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD, LPVOID)
-{
- g_hInst = hInstDLL;
- return TRUE;
-}
diff --git a/plugins/Db3x_mmap/src/stdafx.h b/plugins/Db3x_mmap/src/stdafx.h index d009117695..012e9bb510 100644 --- a/plugins/Db3x_mmap/src/stdafx.h +++ b/plugins/Db3x_mmap/src/stdafx.h @@ -33,8 +33,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <process.h>
#include <memory>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <win2k.h>
#include <m_system.h>
@@ -55,8 +53,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "resource.h"
#include "version.h"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(nullptr)
+ {}
+};
-extern HINSTANCE g_hInst;
extern LIST<CDb3Mmap> g_Dbs;
extern DBSignature dbSignatureU, dbSignatureE, dbSignatureIM, dbSignatureSA, dbSignatureSD;
diff --git a/plugins/Db3x_mmap/src/ui.cpp b/plugins/Db3x_mmap/src/ui.cpp index 02ed2acfc4..9a5583e778 100644 --- a/plugins/Db3x_mmap/src/ui.cpp +++ b/plugins/Db3x_mmap/src/ui.cpp @@ -63,7 +63,7 @@ static INT_PTR CALLBACK sttEnterPassword(HWND hwndDlg, UINT uMsg, WPARAM wParam, switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(iconList[0].defIconID)));
+ SendDlgItemMessage(hwndDlg, IDC_HEADERBAR, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(iconList[0].defIconID)));
param = (DlgChangePassParam*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
@@ -140,7 +140,7 @@ bool CDb3Mmap::EnterPassword(const BYTE *pKey, const size_t keyLen) CredFree(pCred);
}
else {
- if (IDOK != DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_LOGIN), nullptr, sttEnterPassword, (LPARAM)¶m))
+ if (IDOK != DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_LOGIN), nullptr, sttEnterPassword, (LPARAM)¶m))
return false;
m_crypto->setPassword(T2Utf(param.newPass));
}
@@ -258,7 +258,7 @@ static INT_PTR ChangePassword(void* obj, WPARAM, LPARAM) {
CDb3Mmap *db = (CDb3Mmap*)obj;
DlgChangePassParam param = { db };
- DialogBoxParam(g_hInst, MAKEINTRESOURCE(db->usesPassword() ? IDD_CHANGEPASS : IDD_NEWPASS), nullptr, sttChangePassword, (LPARAM)¶m);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(db->usesPassword() ? IDD_CHANGEPASS : IDD_NEWPASS), nullptr, sttChangePassword, (LPARAM)¶m);
return 0;
}
@@ -304,7 +304,7 @@ static int OnOptionsInit(PVOID obj, WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -790000000;
- odp.hInstance = g_hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.flags = ODPF_BOLDGROUPS;
odp.szTitle.a = LPGEN("Database");
@@ -325,7 +325,7 @@ static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM) {
CDb3Mmap *db = (CDb3Mmap*)obj;
- Icon_Register(g_hInst, LPGEN("Database"), iconList, _countof(iconList), "mmap");
+ Icon_Register(g_plugin.getInst(), LPGEN("Database"), iconList, _countof(iconList), "mmap");
HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, db);
diff --git a/plugins/Db3x_mmap/src/ui.h b/plugins/Db3x_mmap/src/ui.h index aee1ff0d82..ae438fcab7 100644 --- a/plugins/Db3x_mmap/src/ui.h +++ b/plugins/Db3x_mmap/src/ui.h @@ -9,7 +9,7 @@ class CSelectCryptoDialog : public CDlgBase CRYPTO_PROVIDER *m_selected;
public:
CSelectCryptoDialog(CRYPTO_PROVIDER **provs, size_t count) :
- CDlgBase(g_hInst, IDD_SELECT_CRYPTOPROVIDER),
+ CDlgBase(g_plugin.getInst(), IDD_SELECT_CRYPTOPROVIDER),
m_combo(this, IDC_SELECTCRYPT_COMBO),
m_descr(this, IDC_CRYPTOPROVIDER_DESCR),
m_provs(provs),
diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp index 23d332ad8a..21c6c3a988 100644 --- a/plugins/Dbx_mdbx/src/dbintf.cpp +++ b/plugins/Dbx_mdbx/src/dbintf.cpp @@ -32,7 +32,7 @@ CDbxMDBX::CDbxMDBX(const TCHAR *tszFileName, int iMode) : m_tszProfileName = mir_wstrdup(tszFileName);
if (!m_bReadOnly) {
- m_hwndTimer = CreateWindowExW(0, L"STATIC", nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_hInst, nullptr);
+ m_hwndTimer = CreateWindowExW(0, L"STATIC", nullptr, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, nullptr, g_plugin.getInst(), nullptr);
::SetWindowLongPtr(m_hwndTimer, GWLP_USERDATA, (LONG_PTR)this);
}
diff --git a/plugins/Dbx_mdbx/src/init.cpp b/plugins/Dbx_mdbx/src/init.cpp index 2500cd30ad..bedddf12fa 100644 --- a/plugins/Dbx_mdbx/src/init.cpp +++ b/plugins/Dbx_mdbx/src/init.cpp @@ -25,12 +25,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. EXTERN_C void NTAPI tls_callback(PVOID module, DWORD reason, PVOID reserved);
-HINSTANCE g_hInst = nullptr;
int hLangpack;
+CMPlugin g_plugin;
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID reserved)
{
- g_hInst = hInstDLL;
tls_callback(hInstDLL, reason, reserved);
return TRUE;
}
diff --git a/plugins/Dbx_mdbx/src/stdafx.h b/plugins/Dbx_mdbx/src/stdafx.h index f394e09f3a..50031647f5 100644 --- a/plugins/Dbx_mdbx/src/stdafx.h +++ b/plugins/Dbx_mdbx/src/stdafx.h @@ -34,8 +34,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <map>
#include <cassert>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <win2k.h>
#include <m_system_cpp.h>
@@ -164,6 +162,12 @@ public: #include "resource.h"
#include "version.h"
-extern HINSTANCE g_hInst;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(nullptr)
+ {}
+};
#include "ui.h"
+
diff --git a/plugins/Dbx_mdbx/src/ui.cpp b/plugins/Dbx_mdbx/src/ui.cpp index a45fb02082..a7d9566dca 100644 --- a/plugins/Dbx_mdbx/src/ui.cpp +++ b/plugins/Dbx_mdbx/src/ui.cpp @@ -146,7 +146,7 @@ static INT_PTR ChangePassword(void* obj, WPARAM, LPARAM) {
CDbxMDBX *db = (CDbxMDBX*)obj;
DlgChangePassParam param = { db };
- DialogBoxParam(g_hInst, MAKEINTRESOURCE(db->usesPassword() ? IDD_CHANGEPASS : IDD_NEWPASS), nullptr, sttChangePassword, (LPARAM)¶m);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(db->usesPassword() ? IDD_CHANGEPASS : IDD_NEWPASS), nullptr, sttChangePassword, (LPARAM)¶m);
return 0;
}
@@ -182,7 +182,7 @@ static int OnModulesLoaded(PVOID obj, WPARAM, LPARAM) {
CDbxMDBX *db = (CDbxMDBX*)obj;
- Icon_Register(g_hInst, LPGEN("Database"), iconList, _countof(iconList), "mdbx");
+ Icon_Register(g_plugin.getInst(), LPGEN("Database"), iconList, _countof(iconList), "mdbx");
HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, db);
diff --git a/plugins/Dbx_mdbx/src/ui.h b/plugins/Dbx_mdbx/src/ui.h index dc1a87c2e9..a76cedf625 100644 --- a/plugins/Dbx_mdbx/src/ui.h +++ b/plugins/Dbx_mdbx/src/ui.h @@ -40,7 +40,7 @@ class COptionsDialog : public CDlgBase public:
COptionsDialog(CDbxMDBX *db) :
- CDlgBase(g_hInst, IDD_OPTIONS),
+ CDlgBase(g_plugin.getInst(), IDD_OPTIONS),
m_chkStandart(this, IDC_STANDARD),
m_chkTotal(this, IDC_TOTAL),
m_btnChangePass(this, IDC_USERPASS),
@@ -84,7 +84,7 @@ class CSelectCryptoDialog : public CDlgBase public:
CSelectCryptoDialog(CRYPTO_PROVIDER **provs, size_t count) :
- CDlgBase(g_hInst, IDD_SELECT_CRYPTOPROVIDER),
+ CDlgBase(g_plugin.getInst(), IDD_SELECT_CRYPTOPROVIDER),
m_combo(this, IDC_SELECTCRYPT_COMBO),
m_descr(this, IDC_CRYPTOPROVIDER_DESCR),
m_chkTotalCrypt(this, IDC_CHECK_TOTALCRYPT),
@@ -146,7 +146,7 @@ class CEnterPasswordDialog : public CDlgBase void OnInitDialog()
{
- m_header.SendMsg(WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(iconList[0].defIconID)));
+ m_header.SendMsg(WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(iconList[0].defIconID)));
if (m_param->wrongPass)
{
if (m_param->wrongPass > 2)
@@ -180,7 +180,7 @@ class CEnterPasswordDialog : public CDlgBase public:
CEnterPasswordDialog(DlgChangePassParam *param) :
- CDlgBase(g_hInst, IDD_LOGIN),
+ CDlgBase(g_plugin.getInst(), IDD_LOGIN),
m_header(this, IDC_HEADERBAR),
m_language(this, IDC_LANG),
m_passwordEdit(this, IDC_USERPASS),
diff --git a/plugins/Exchange/src/emails.cpp b/plugins/Exchange/src/emails.cpp index 7298a6b902..1cc625746d 100644 --- a/plugins/Exchange/src/emails.cpp +++ b/plugins/Exchange/src/emails.cpp @@ -326,7 +326,7 @@ int ShowEmailsWindow(int cUnreadEmails) {
if (cUnreadEmails > 0) { //show window only if there are unread emails
if (!hEmailsDlg)
- hEmailsDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EMAILS), nullptr, DlgProcEmails);
+ hEmailsDlg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EMAILS), nullptr, DlgProcEmails);
SetWindowLongPtr(hEmailsDlg, GWLP_USERDATA, cUnreadEmails);
if (IsWindowVisible(hEmailsDlg))
diff --git a/plugins/Exchange/src/exchange.cpp b/plugins/Exchange/src/exchange.cpp index d9932b1b80..2c80074eda 100644 --- a/plugins/Exchange/src/exchange.cpp +++ b/plugins/Exchange/src/exchange.cpp @@ -20,15 +20,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-char ModuleName[] = "ExchangeNotify";
-HINSTANCE hInstance;
HICON hiMailIcon = nullptr;
HWND hEmailsDlg = nullptr;
int hLangpack=0;
+CMPlugin g_plugin;
CExchangeServer exchangeServer;
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfo =
+{
sizeof(PLUGININFOEX),
__PLUGIN_DISPLAY_NAME,
__VERSION_DWORD,
@@ -45,31 +47,22 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD) return &pluginInfo;
}
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_EXCHANGE, MIID_LAST};
+/////////////////////////////////////////////////////////////////////////////////////////
extern "C" int __declspec(dllexport) Load()
{
mir_getLP( &pluginInfo );
- hiMailIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIL));
+ hiMailIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_MAIL));
InitServices();
HookEvents();
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload()
{
DestroyServices();
UnhookEvents();
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID)
-{
- hInstance = hinstDLL; //save global instance
- if (fdwReason == DLL_PROCESS_ATTACH)
- DisableThreadLibraryCalls(hinstDLL);
-
- return TRUE;
-}
diff --git a/plugins/Exchange/src/hooked_events.cpp b/plugins/Exchange/src/hooked_events.cpp index 31c57720c9..702b8ad7b1 100644 --- a/plugins/Exchange/src/hooked_events.cpp +++ b/plugins/Exchange/src/hooked_events.cpp @@ -63,7 +63,7 @@ int OnModulesLoaded(WPARAM, LPARAM) mi.name.w = LPGENW("Check exchange mailbox");
Menu_AddMainMenuItem(&mi);
- hEmailsDlg = nullptr; //CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EMAILS), NULL, DlgProcEmails); //create emails window
+ hEmailsDlg = nullptr; //CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EMAILS), NULL, DlgProcEmails); //create emails window
FirstTimeCheck();
// CheckEmail();
return 0;
@@ -74,7 +74,7 @@ int OnOptionsInitialise(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = 100000000;
- odp.hInstance = hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_EXCHANGE);
odp.szTitle.w = LPGENW("Exchange notify");
odp.szGroup.w = LPGENW("Plugins");
diff --git a/plugins/Exchange/src/stdafx.h b/plugins/Exchange/src/stdafx.h index 5c04e1c8f7..213ee4ea42 100644 --- a/plugins/Exchange/src/stdafx.h +++ b/plugins/Exchange/src/stdafx.h @@ -31,8 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <stdlib.h>
#include <string.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_core.h>
#include <m_popup.h>
@@ -50,11 +48,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "services.h"
#include "hooked_events.h"
-extern char ModuleName[];
-extern HINSTANCE hInstance;
+#define ModuleName "ExchangeNotify"
+
extern HICON hiMailIcon;
extern HWND hEmailsDlg;
-
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(ModuleName)
+ {}
+};
#endif //M_EXCHANGE_COMMONHEADERS_H
\ No newline at end of file diff --git a/plugins/LotusNotify/src/LotusNotify.cpp b/plugins/LotusNotify/src/LotusNotify.cpp index b893f7ce50..8eefe07da2 100644 --- a/plugins/LotusNotify/src/LotusNotify.cpp +++ b/plugins/LotusNotify/src/LotusNotify.cpp @@ -23,6 +23,7 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM lParam); char PLUGINNAME[64] = {0}; //init at init_pluginname();
int hLangpack = 0;
+CMPlugin g_plugin;
CLIST_INTERFACE *pcli;
HINSTANCE hLotusDll;
@@ -88,10 +89,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD) /////////////////////////////////////////////////////////////////////////////////////////
-CMPlugin g_plugin;
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/LotusNotify/src/stdafx.h b/plugins/LotusNotify/src/stdafx.h index bb7b1c3186..661f9c5977 100644 --- a/plugins/LotusNotify/src/stdafx.h +++ b/plugins/LotusNotify/src/stdafx.h @@ -9,8 +9,6 @@ // Miranda headers
//LotusNotify.h
-#define __NO_CMPLUGIN_NEEDED
-
#include <m_core.h>
#include <win2k.h>
#include <newpluginapi.h>
@@ -38,5 +36,3 @@ #include "cnotesapi/include/extmgr.h"
#include "cnotesapi/include/bsafeerr.h"
#include "cnotesapi/include/nsferr.h"
-
-
diff --git a/plugins/MagneticWindows/src/stdafx.h b/plugins/MagneticWindows/src/stdafx.h index ba6c7229ce..7e4a0df923 100644 --- a/plugins/MagneticWindows/src/stdafx.h +++ b/plugins/MagneticWindows/src/stdafx.h @@ -17,13 +17,11 @@ #include "resource.h" #include "Version.h" -typedef -struct { +struct TWorkingVariables +{ int MouseX, MouseY; bool SnappedX, SnappedY; -} TWorkingVariables; - - +}; #define MODULE_NAME "MagneticWindows" diff --git a/plugins/MobileState/src/main.cpp b/plugins/MobileState/src/main.cpp index 46a3f348f1..2ced60c6cb 100644 --- a/plugins/MobileState/src/main.cpp +++ b/plugins/MobileState/src/main.cpp @@ -19,10 +19,15 @@ #include "stdafx.h"
-HINSTANCE g_hInst;
int hLangpack;
+CMPlugin g_plugin;
+
HANDLE hExtraIcon = nullptr;
+static IconItem icon = { LPGEN("Mobile State"), "mobile_icon", IDI_MOBILE };
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -36,19 +41,13 @@ PLUGININFOEX pluginInfo = { { 0xf0ba32d0, 0xcd07, 0x4a9c, { 0x92, 0x6b, 0x5a, 0x1f, 0xf2, 0x1c, 0x3c, 0x10 } }
};
-static IconItem icon = { LPGEN("Mobile State"), "mobile_icon", IDI_MOBILE };
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- g_hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
bool hasMobileClient(MCONTACT hContact, LPARAM)
{
char *proto = GetContactProto(hContact);
@@ -67,7 +66,9 @@ bool hasMobileClient(MCONTACT hContact, LPARAM) return false;
}
-int ExtraIconsApply(WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int ExtraIconsApply(WPARAM wParam, LPARAM lParam)
{
if (wParam == NULL)
return 0;
@@ -80,7 +81,7 @@ int ExtraIconsApply(WPARAM wParam, LPARAM lParam) return 0;
}
-int onContactSettingChanged(WPARAM wParam, LPARAM lParam)
+static int onContactSettingChanged(WPARAM wParam, LPARAM lParam)
{
char *proto = GetContactProto(wParam);
if (!proto)
@@ -93,7 +94,7 @@ int onContactSettingChanged(WPARAM wParam, LPARAM lParam) return 0;
}
-int onModulesLoaded(WPARAM, LPARAM)
+static int onModulesLoaded(WPARAM, LPARAM)
{
// Set initial value for all contacts
for (auto &hContact : Contacts())
@@ -111,13 +112,15 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, ExtraIconsApply);
// IcoLib support
- Icon_Register(g_hInst, "Mobile State", &icon, 1);
+ Icon_Register(g_plugin.getInst(), "Mobile State", &icon, 1);
// Extra icons
hExtraIcon = ExtraIcon_RegisterIcolib("mobilestate", LPGEN("Mobile State"), "mobile_icon");
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
return 0;
diff --git a/plugins/MobileState/src/stdafx.h b/plugins/MobileState/src/stdafx.h index d0090adf55..0c59a5a1bd 100644 --- a/plugins/MobileState/src/stdafx.h +++ b/plugins/MobileState/src/stdafx.h @@ -23,7 +23,6 @@ #include <malloc.h>
// Miranda API headers
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_database.h>
#include <m_protocols.h>
@@ -37,3 +36,10 @@ #include "clients.h"
#define MODULENAME "MobileState"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
diff --git a/plugins/MyDetails/src/frame.cpp b/plugins/MyDetails/src/frame.cpp index 505752efc4..fffd5399ee 100644 --- a/plugins/MyDetails/src/frame.cpp +++ b/plugins/MyDetails/src/frame.cpp @@ -262,7 +262,7 @@ int CreateFrame() wndclass.lpfnWndProc = FrameWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
+ wndclass.hInstance = g_plugin.getInst();
wndclass.hIcon = nullptr;
wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
wndclass.hbrBackground = nullptr; //(HBRUSH)(COLOR_3DFACE+1);
@@ -272,7 +272,7 @@ int CreateFrame() if (g_bFramesExist) {
hwnd_frame = CreateWindow(WINDOW_CLASS_NAME, TranslateT("My details"), WS_CHILD | WS_VISIBLE,
- 0, 0, 10, 10, pcli->hwndContactList, nullptr, hInst, nullptr);
+ 0, 0, 10, 10, pcli->hwndContactList, nullptr, g_plugin.getInst(), nullptr);
CLISTFrame Frame = { 0 };
@@ -307,7 +307,7 @@ int CreateFrame() wndclass.lpfnWndProc = FrameContainerWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
+ wndclass.hInstance = g_plugin.getInst();
wndclass.hIcon = nullptr;
wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
wndclass.hbrBackground = nullptr; //(HBRUSH)(COLOR_3DFACE+1);
@@ -317,10 +317,10 @@ int CreateFrame() hwnd_container = CreateWindowEx(WS_EX_TOOLWINDOW, CONTAINER_CLASS_NAME, TranslateT("My details"),
(WS_THICKFRAME | WS_CAPTION | WS_SYSMENU) & ~WS_VISIBLE,
- 0, 0, 200, 130, pcli->hwndContactList, nullptr, hInst, nullptr);
+ 0, 0, 200, 130, pcli->hwndContactList, nullptr, g_plugin.getInst(), nullptr);
hwnd_frame = CreateWindow(WINDOW_CLASS_NAME, TranslateT("My details"), WS_CHILD | WS_VISIBLE,
- 0, 0, 10, 10, hwnd_container, nullptr, hInst, nullptr);
+ 0, 0, 10, 10, hwnd_container, nullptr, g_plugin.getInst(), nullptr);
SetWindowLongPtr(hwnd_container, GWLP_USERDATA, (LONG_PTR)hwnd_frame);
SendMessage(hwnd_container, WM_SIZE, 0, 0);
@@ -528,14 +528,14 @@ HWND CreateTooltip(HWND hwnd, RECT &rect) /* CREATE A TOOLTIP WINDOW */
HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, nullptr, hInst, nullptr); // handle to the ToolTip control
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, nullptr, g_plugin.getInst(), nullptr); // handle to the ToolTip control
/* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS;
ti.hwnd = hwnd;
- ti.hinst = hInst;
+ ti.hinst = g_plugin.getInst();
ti.uId = uid;
ti.lpszText = LPSTR_TEXTCALLBACK;
// ToolTip control will cover the whole window
@@ -1187,7 +1187,7 @@ void Draw(HWND hwnd, HDC hdc_orig) HICON icon = IcoLib_GetIcon("MYDETAILS_NEXT_PROTOCOL");
if (icon == nullptr)
- icon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RIGHT_ARROW));
+ icon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RIGHT_ARROW));
DrawIconEx(hdc, data->next_proto_rect.left, data->next_proto_rect.top, icon, ICON_SIZE, ICON_SIZE, 0, nullptr, DI_NORMAL);
IcoLib_ReleaseIcon(icon);
@@ -1200,7 +1200,7 @@ void Draw(HWND hwnd, HDC hdc_orig) icon = IcoLib_GetIcon("MYDETAILS_PREV_PROTOCOL");
if (icon == nullptr)
- icon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RIGHT_ARROW));
+ icon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RIGHT_ARROW));
DrawIconEx(hdc, data->prev_proto_rect.left, data->prev_proto_rect.top, icon, ICON_SIZE, ICON_SIZE, 0, nullptr, DI_NORMAL);
IcoLib_ReleaseIcon(icon);
@@ -1324,7 +1324,7 @@ void Draw(HWND hwnd, HDC hdc_orig) HICON icon = IcoLib_GetIcon("LISTENING_TO_ICON");
if (icon == nullptr)
- icon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_LISTENINGTO));
+ icon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_LISTENINGTO));
DrawIconEx(hdc, data->listening_to_icon_rect.left, data->listening_to_icon_rect.top, icon, ICON_SIZE, ICON_SIZE, 0, nullptr, DI_NORMAL);
IcoLib_ReleaseIcon(icon);
@@ -1448,7 +1448,7 @@ void ShowProtocolStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto static unsigned statusModePf2List[] = { 0xFFFFFFFF, PF2_ONLINE, PF2_SHORTAWAY, PF2_LONGAWAY, PF2_LIGHTDND, PF2_HEAVYDND, PF2_FREECHAT,
PF2_INVISIBLE, PF2_ONTHEPHONE, PF2_OUTTOLUNCH };
- menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1));
+ menu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1));
submenu = GetSubMenu(menu, 0);
TranslateMenu(submenu);
@@ -1472,7 +1472,7 @@ void ShowProtocolStatusMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto void ShowListeningToMenu(HWND hwnd, MyDetailsFrameData *data, Protocol *proto, POINT &p)
{
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1));
+ HMENU menu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1));
HMENU submenu = GetSubMenu(menu, 5);
TranslateMenu(submenu);
@@ -1710,7 +1710,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar // In image?
if (data->draw_img && InsideRect(&p, &data->img_rect)) {
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1));
+ HMENU menu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1));
HMENU submenu = GetSubMenu(menu, 4);
TranslateMenu(submenu);
@@ -1750,7 +1750,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar }
// In nick?
else if (data->draw_nick && InsideRect(&p, &data->nick_rect)) {
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1));
+ HMENU menu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1));
HMENU submenu = GetSubMenu(menu, 2);
TranslateMenu(submenu);
@@ -1798,7 +1798,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar else if (data->draw_away_msg && InsideRect(&p, &data->away_msg_rect)) {
wchar_t tmp[128];
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1));
+ HMENU menu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1));
HMENU submenu = GetSubMenu(menu, 3);
TranslateMenu(submenu);
@@ -1875,7 +1875,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar }
// Default context menu
else {
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1));
+ HMENU menu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU1));
HMENU submenu = GetSubMenu(menu, 1);
TranslateMenu(submenu);
diff --git a/plugins/MyDetails/src/mydetails.cpp b/plugins/MyDetails/src/mydetails.cpp index 5f00d1a8dd..aad7b0c45f 100644 --- a/plugins/MyDetails/src/mydetails.cpp +++ b/plugins/MyDetails/src/mydetails.cpp @@ -19,12 +19,19 @@ Boston, MA 02111-1307, USA. #include "stdafx.h"
+int hLangpack;
+CMPlugin g_plugin;
CLIST_INTERFACE *pcli;
-HINSTANCE hInst;
-int hLangpack = 0;
bool g_bAvsExist;
+static IconItem iconList[] =
+{
+ { LPGEN("Listening to"), "LISTENING_TO_ICON", IDI_LISTENINGTO },
+ { LPGEN("Previous account"), "MYDETAILS_PREV_PROTOCOL", IDI_LEFT_ARROW },
+ { LPGEN("Next account"), "MYDETAILS_NEXT_PROTOCOL", IDI_RIGHT_ARROW }
+};
+
// Plugin data ////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfo = {
@@ -40,21 +47,6 @@ PLUGININFOEX pluginInfo = { { 0xa82baeb3, 0xa33c, 0x4036, { 0xb8, 0x37, 0x78, 0x3, 0xa5, 0xb6, 0xc2, 0xab } }
};
-static IconItem iconList[] =
-{
- { LPGEN("Listening to"), "LISTENING_TO_ICON", IDI_LISTENINGTO },
- { LPGEN("Previous account"), "MYDETAILS_PREV_PROTOCOL", IDI_LEFT_ARROW },
- { LPGEN("Next account"), "MYDETAILS_NEXT_PROTOCOL", IDI_RIGHT_ARROW }
-};
-
-// Functions //////////////////////////////////////////////////////////////////////////////////////
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
@@ -153,9 +145,9 @@ extern "C" __declspec(dllexport) int Load() InitOptions();
if (IcoLib_GetIcon("LISTENING_TO_ICON") == nullptr)
- Icon_Register(hInst, LPGEN("Contact list"), iconList, 1);
+ Icon_Register(g_plugin.getInst(), LPGEN("Contact list"), iconList, 1);
- Icon_Register(hInst, LPGEN("My details"), iconList + 1, _countof(iconList) - 1);
+ Icon_Register(g_plugin.getInst(), LPGEN("My details"), iconList + 1, _countof(iconList) - 1);
// Register services
CreateServiceFunction(MS_MYDETAILS_SETMYNICKNAME, PluginCommand_SetMyNickname);
diff --git a/plugins/MyDetails/src/options.cpp b/plugins/MyDetails/src/options.cpp index 625984cf9f..67ad87d1f7 100644 --- a/plugins/MyDetails/src/options.cpp +++ b/plugins/MyDetails/src/options.cpp @@ -163,7 +163,7 @@ int InitOptionsCallback(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -200000000;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pfnDlgProc = DlgProcOpts;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTS);
odp.szGroup.w = LPGENW("Contact list");
diff --git a/plugins/MyDetails/src/services.cpp b/plugins/MyDetails/src/services.cpp index 807d901180..83b54b4c3c 100644 --- a/plugins/MyDetails/src/services.cpp +++ b/plugins/MyDetails/src/services.cpp @@ -147,7 +147,7 @@ INT_PTR PluginCommand_SetMyNicknameUI(WPARAM, LPARAM lParam) if (!nickname_dialog_open) {
InterlockedExchange(&nickname_dialog_open, 1);
- hwndSetNickname = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SETNICKNAME), nullptr, DlgProcSetNickname);
+ hwndSetNickname = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SETNICKNAME), nullptr, DlgProcSetNickname);
SendMessage(hwndSetNickname, WMU_SETDATA, proto_num, 0);
}
@@ -437,7 +437,7 @@ INT_PTR PluginCommand_SetMyStatusMessageUI(WPARAM wParam, LPARAM lParam) if (!status_msg_dialog_open) {
InterlockedExchange(&status_msg_dialog_open, 1);
- hwndSetStatusMsg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SETSTATUSMESSAGE), nullptr, DlgProcSetStatusMessage);
+ hwndSetStatusMsg = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SETSTATUSMESSAGE), nullptr, DlgProcSetStatusMessage);
SendMessage(hwndSetStatusMsg, WMU_SETDATA, status, proto_num);
}
diff --git a/plugins/MyDetails/src/stdafx.h b/plugins/MyDetails/src/stdafx.h index f5ae61ac93..9383f39392 100644 --- a/plugins/MyDetails/src/stdafx.h +++ b/plugins/MyDetails/src/stdafx.h @@ -25,8 +25,6 @@ Boston, MA 02111-1307, USA. #include <windowsx.h>
#include <commctrl.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_skin.h>
#include <m_protosvc.h>
@@ -65,7 +63,13 @@ Boston, MA 02111-1307, USA. #define SETTING_FRAME_VISIBLE "FrameVisible"
#define SETTING_DEFAULT_NICK "DefaultNick"
-extern HINSTANCE hInst;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE_NAME)
+ {}
+};
+
extern bool g_bFramesExist, g_bAvsExist;
#define PS_GETMYNICKNAMEMAXLENGTH "/GetMyNicknameMaxLength"
diff --git a/plugins/NewsAggregator/Src/stdafx.h b/plugins/NewsAggregator/Src/stdafx.h index 0e9e76570b..834e47b174 100644 --- a/plugins/NewsAggregator/Src/stdafx.h +++ b/plugins/NewsAggregator/Src/stdafx.h @@ -30,7 +30,6 @@ Boston, MA 02111-1307, USA. #include <mshtml.h>
// Miranda header files
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_langpack.h>
diff --git a/plugins/Non-IM Contact/src/stdafx.h b/plugins/Non-IM Contact/src/stdafx.h index a1ca8f42ba..1497c970df 100644 --- a/plugins/Non-IM Contact/src/stdafx.h +++ b/plugins/Non-IM Contact/src/stdafx.h @@ -30,7 +30,6 @@ struct DLGTEMPLATEEX short cy;
};
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clistint.h>
#include <m_skin.h>
diff --git a/plugins/Quotes/src/stdafx.h b/plugins/Quotes/src/stdafx.h index aa2794e886..ea4fed341e 100644 --- a/plugins/Quotes/src/stdafx.h +++ b/plugins/Quotes/src/stdafx.h @@ -15,7 +15,6 @@ #include <fstream>
#include <msapi/comptr.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_database.h>
#include <win2k.h>
diff --git a/plugins/Rate/src/main.cpp b/plugins/Rate/src/main.cpp index f0df6cdaa6..0e6d3a20ca 100644 --- a/plugins/Rate/src/main.cpp +++ b/plugins/Rate/src/main.cpp @@ -35,11 +35,20 @@ #include "stdafx.h"
-HINSTANCE g_hInst;
-
static HANDLE hExtraIcon = nullptr;
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+}
+g_plugin;
+
int hLangpack;
+///////////////////////////////////////////////////////////////////////////////
+
PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
@@ -54,12 +63,6 @@ PLUGININFOEX pluginInfo = {0x45230488, 0x977b, 0x405b, {0x85, 0x6d, 0xea, 0x27, 0x6d, 0x70, 0x83, 0xb7}}
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- g_hInst = hinstDLL;
- return TRUE;
-}
-
// плагининфо
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
@@ -123,13 +126,15 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged);
// IcoLib support
- Icon_Register(g_hInst, LPGEN("Contact rate"), iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), LPGEN("Contact rate"), iconList, _countof(iconList));
// Extra icon support
hExtraIcon = ExtraIcon_RegisterIcolib("contact_rate", LPGEN("Contact rate"), "rate_high");
return 0;
}
+///////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
return 0;
diff --git a/plugins/Rate/src/stdafx.h b/plugins/Rate/src/stdafx.h index f8b23375a5..9226bf1c7a 100644 --- a/plugins/Rate/src/stdafx.h +++ b/plugins/Rate/src/stdafx.h @@ -18,12 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef COMMHEADERS_H
-#define COMMHEADERS_H
-
#include <windows.h>
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_database.h>
@@ -34,5 +30,3 @@ #include "version.h"
#define MODULENAME "Rate"
-
-#endif //COMMHEADERS_H
diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp index 8a8cbf3003..d65e97e226 100644 --- a/plugins/RecentContacts/src/RecentContacts.cpp +++ b/plugins/RecentContacts/src/RecentContacts.cpp @@ -7,8 +7,8 @@ using namespace std; static const basic_string <char>::size_type npos = -1;
char *szProto;
-HINSTANCE hInst = nullptr;
int hLangpack = 0;
+CMPlugin g_plugin;
CHAT_MANAGER *pci;
CLIST_INTERFACE *pcli;
@@ -20,13 +20,7 @@ const INT_PTR boo = 0; LastUCOptions LastUCOpt = {0};
-/////////////////////////////////////////////////////////////////////////////////////////
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
+static IconItem icon = { LPGEN("Main icon"), "recent_main", IDI_SHOWRECENT };
/////////////////////////////////////////////////////////////////////////////////////////
@@ -44,8 +38,6 @@ PLUGININFOEX pluginInfo = {0x0e5f3b9d, 0xebcd, 0x44d7, {0x93, 0x74, 0xd8, 0xe5, 0xd8, 0x8d, 0xf4, 0xe3}}
};
-static IconItem icon = { LPGEN("Main icon"), "recent_main", IDI_SHOWRECENT };
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
@@ -251,13 +243,12 @@ INT_PTR CALLBACK ShowListMainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lvi.iImage = Clist_GetContactIcon(curContact->second);
ListView_InsertItem(hList, &lvi);
i++;
-
}
+
if (LastUCOpt.MaxShownContacts > 0 && i >= LastUCOpt.MaxShownContacts)
break;
}
-
// window autosize/autopos - ike blaster
bool restorePos = !LastUCOpt.WindowAutoSize;
@@ -300,37 +291,35 @@ INT_PTR CALLBACK ShowListMainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM break;
case WM_NOTIFY:
- {
- LPNMHDR lpNmhdr;
- lpNmhdr = (LPNMHDR)lParam;
- if (lpNmhdr->hwndFrom == hList) {
- if (lpNmhdr->code == NM_CLICK || lpNmhdr->code == NM_RCLICK) {
- RECT r;
- POINT p;
- GetCursorPos(&p);
- GetWindowRect(hList, &r);
- if (PtInRect(&r, p)) {
- LVHITTESTINFO lvh;
- memset(&lvh, 0, sizeof(lvh));
- lvh.pt = p;
- ScreenToClient(hList, &lvh.pt);
- ListView_HitTest(hList, &lvh);
- if ((lvh.flags & (LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON)) && lvh.iItem != -1) {
- if (lpNmhdr->code == NM_CLICK) {
- if (ShowListMainDlgProc_OpenContact(hList, lvh.iItem))
- SendMessage(hDlg, WM_CLOSE, 0, 0);
- }
- else ShowListMainDlgProc_OpenContactMenu(hDlg, hList, lvh.iItem, DlgDat);
+ LPNMHDR lpNmhdr;
+ lpNmhdr = (LPNMHDR)lParam;
+ if (lpNmhdr->hwndFrom == hList) {
+ if (lpNmhdr->code == NM_CLICK || lpNmhdr->code == NM_RCLICK) {
+ RECT r;
+ POINT p;
+ GetCursorPos(&p);
+ GetWindowRect(hList, &r);
+ if (PtInRect(&r, p)) {
+ LVHITTESTINFO lvh;
+ memset(&lvh, 0, sizeof(lvh));
+ lvh.pt = p;
+ ScreenToClient(hList, &lvh.pt);
+ ListView_HitTest(hList, &lvh);
+ if ((lvh.flags & (LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON)) && lvh.iItem != -1) {
+ if (lpNmhdr->code == NM_CLICK) {
+ if (ShowListMainDlgProc_OpenContact(hList, lvh.iItem))
+ SendMessage(hDlg, WM_CLOSE, 0, 0);
}
+ else ShowListMainDlgProc_OpenContactMenu(hDlg, hList, lvh.iItem, DlgDat);
}
}
- else if (lpNmhdr->code == NM_RETURN) {
- if (ShowListMainDlgProc_OpenContact(hList, ListView_GetNextItem(hList, -1, LVIS_SELECTED)))
- SendMessage(hDlg, WM_CLOSE, 0, 0);
- }
}
- break;
+ else if (lpNmhdr->code == NM_RETURN) {
+ if (ShowListMainDlgProc_OpenContact(hList, ListView_GetNextItem(hList, -1, LVIS_SELECTED)))
+ SendMessage(hDlg, WM_CLOSE, 0, 0);
+ }
}
+ break;
case WM_MEASUREITEM:
return Menu_MeasureItem(lParam);
@@ -415,7 +404,7 @@ INT_PTR OnMenuCommandShowList(WPARAM, LPARAM) contacts->insert(cpair(curTime, curContact));
}
- HWND hWndMain = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_LASTUC_DIALOG), nullptr, ShowListMainDlgProc, (LPARAM)contacts);
+ HWND hWndMain = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_LASTUC_DIALOG), nullptr, ShowListMainDlgProc, (LPARAM)contacts);
if (hWndMain == nullptr)
return -1;
@@ -562,7 +551,7 @@ extern "C" __declspec(dllexport) int Load(void) CoInitialize(nullptr);
- Icon_Register(hInst, "Recent Contacts", &icon, 1);
+ Icon_Register(g_plugin.getInst(), "Recent Contacts", &icon, 1);
CreateServiceFunction(msLastUC_ShowList, OnMenuCommandShowList);
CreateServiceFunction(V_RECENTCONTACTS_TOGGLE_IGNORE, ToggleIgnore);
diff --git a/plugins/RecentContacts/src/options.cpp b/plugins/RecentContacts/src/options.cpp index da67bff9bd..3a833f4ba4 100644 --- a/plugins/RecentContacts/src/options.cpp +++ b/plugins/RecentContacts/src/options.cpp @@ -1,6 +1,5 @@ #include "stdafx.h"
-extern HINSTANCE hInst;
void LoadDBSettings();
static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -59,7 +58,7 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LP int onOptInitialise(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.szGroup.a = LPGEN("Contacts");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_LASTUC_OPT);
odp.szTitle.a = LPGEN("Recent Contacts");
diff --git a/plugins/RecentContacts/src/stdafx.h b/plugins/RecentContacts/src/stdafx.h index 9e809a6b23..e52935fc47 100644 --- a/plugins/RecentContacts/src/stdafx.h +++ b/plugins/RecentContacts/src/stdafx.h @@ -8,7 +8,6 @@ #include <map>
#include <time.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clistint.h>
#include <m_chat_int.h>
@@ -49,6 +48,13 @@ void wfree(char **Data); #define msLastUC_IgnoreOff "RecentContacts/SetIgnoreOff"
#define msLastUC_IgnoreOn "RecentContacts/SetIgnoreOn"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
+
/////////////////////////////////////////////////////////////////////////////////////////
struct LastUCOptions
diff --git a/plugins/Spamotron/src/stdafx.h b/plugins/Spamotron/src/stdafx.h index 859d41a792..57abf24758 100644 --- a/plugins/Spamotron/src/stdafx.h +++ b/plugins/Spamotron/src/stdafx.h @@ -5,7 +5,6 @@ #include <stdlib.h>
#include <time.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_database.h>
#include <m_system.h>
@@ -160,4 +159,4 @@ struct CMPlugin : public PLUGIN<CMPlugin> #ifdef _DEBUG
extern sqlite3 *bayesdbg;
#define BAYESDBG_FILENAME "bayes.dbg"
-#endif
\ No newline at end of file +#endif
diff --git a/plugins/TopToolBar/src/main.cpp b/plugins/TopToolBar/src/main.cpp index 3b0339e9fc..ee8cdebcdc 100644 --- a/plugins/TopToolBar/src/main.cpp +++ b/plugins/TopToolBar/src/main.cpp @@ -1,9 +1,25 @@ #include "stdafx.h"
-CLIST_INTERFACE *pcli;
-HINSTANCE hInst;
int hLangpack;
+CMPlugin g_plugin;
+CLIST_INTERFACE *pcli;
+
+IconItem iconList[] =
+{
+ { LPGEN("Execute"), "run", IDI_RUN },
+ { LPGEN("Hide offline contacts"), "hide_offline", IDI_HIDEOFFLINE },
+ { LPGEN("Show offline contacts"), "show_offline", IDI_SHOWOFFLINE },
+ { LPGEN("Disable groups"), "groups_off", IDI_GROUPSOFF },
+ { LPGEN("Enable groups"), "groups_on", IDI_GROUPSON },
+ { LPGEN("Disable sounds"), "sounds_off", IDI_SOUNDSOFF },
+ { LPGEN("Enable sounds"), "sounds_on", IDI_SOUNDSON },
+ { LPGEN("Disable metacontacts"), "meta_off", IDI_METAON },
+ { LPGEN("Enable metacontacts"), "meta_on", IDI_METAOFF },
+ { LPGEN("Separator"), "separator", IDI_SEPARATOR }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfo =
{
@@ -24,20 +40,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) return &pluginInfo;
}
-IconItem iconList[] =
-{
- { LPGEN("Execute"), "run", IDI_RUN },
- { LPGEN("Hide offline contacts"), "hide_offline", IDI_HIDEOFFLINE },
- { LPGEN("Show offline contacts"), "show_offline", IDI_SHOWOFFLINE },
- { LPGEN("Disable groups"), "groups_off", IDI_GROUPSOFF },
- { LPGEN("Enable groups"), "groups_on", IDI_GROUPSON },
- { LPGEN("Disable sounds"), "sounds_off", IDI_SOUNDSOFF },
- { LPGEN("Enable sounds"), "sounds_on", IDI_SOUNDSON },
- { LPGEN("Disable metacontacts"), "meta_off", IDI_METAON },
- { LPGEN("Enable metacontacts"), "meta_on", IDI_METAOFF },
- { LPGEN("Separator"), "separator", IDI_SEPARATOR }
-};
-
/////////////////////////////////////////////////////////////////////////////////////////
extern "C" int __declspec(dllexport) Load(void)
@@ -45,7 +47,7 @@ extern "C" int __declspec(dllexport) Load(void) mir_getLP(&pluginInfo);
pcli = Clist_GetInterface();
- Icon_Register(hInst, TTB_OPTDIR, iconList, _countof(iconList), TTB_OPTDIR);
+ Icon_Register(g_plugin.getInst(), TTB_OPTDIR, iconList, _countof(iconList), TTB_OPTDIR);
LoadToolbarModule();
return 0;
@@ -58,11 +60,3 @@ extern "C" int __declspec(dllexport) Unload(void) UnloadToolbarModule();
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
diff --git a/plugins/TopToolBar/src/stdafx.h b/plugins/TopToolBar/src/stdafx.h index 06f934ee19..b8d387cfde 100644 --- a/plugins/TopToolBar/src/stdafx.h +++ b/plugins/TopToolBar/src/stdafx.h @@ -1,12 +1,10 @@ #ifndef TTB_COMMON_H
#define TTB_COMMON_H
-
#include <windows.h>
#include <commctrl.h>
#include <stddef.h>
-#define __NO_CMPLUGIN_NEEDED
#include <win2k.h>
#include <newpluginapi.h>
#include <m_database.h>
@@ -39,6 +37,13 @@ #define TTBBF_INTERNAL 0x1000000
#define TTBBF_OPTIONAL 0x2000000
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(TTB_OPTDIR)
+ {}
+};
+
///////////////////////////////////////////////////////////////////////////////
// TopButtonInt class
@@ -103,7 +108,6 @@ int ArrangeButtons(); extern TTBCtrl* g_ctrl;
extern LIST<TopButtonInt> Buttons;
-extern HINSTANCE hInst;
extern HBITMAP hBmpBackground;
extern mir_cs csButtonsHook;
extern pfnCustomProc g_CustomProc;
diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp index 7201f1be7c..a3fbea4ad6 100644 --- a/plugins/TopToolBar/src/toolbar.cpp +++ b/plugins/TopToolBar/src/toolbar.cpp @@ -41,8 +41,8 @@ TopButtonInt *idtopos(int id, int *pPos) void InsertSBut(int i)
{
TTBButton ttb = {};
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
- ttb.hIconUp = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.hIconDn = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.hIconUp = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSBUTTON | TTBBF_INTERNAL;
ttb.wParamDown = i;
TTBAddButton((WPARAM)&ttb, 0);
diff --git a/plugins/TopToolBar/src/toolbarwnd.cpp b/plugins/TopToolBar/src/toolbarwnd.cpp index 332585f4f1..cef033447d 100644 --- a/plugins/TopToolBar/src/toolbarwnd.cpp +++ b/plugins/TopToolBar/src/toolbarwnd.cpp @@ -1,309 +1,310 @@ -
-#include "stdafx.h"
-
-COLORREF bkColour;
-HBITMAP hBmpBackground;
-int backgroundBmpUse;
-
-static wchar_t pluginname[] = L"TopToolBar";
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Toolbar window procedure
-
-static void PaintToolbar(HWND hwnd)
-{
- InvalidateRect(hwnd, nullptr, FALSE);
-
- PAINTSTRUCT paintst;
- HDC hdc = BeginPaint(hwnd, &paintst);
- RECT *rcPaint = &paintst.rcPaint;
-
- RECT clRect;
- GetClientRect(hwnd, &clRect);
-
- int yScroll = 0;
-
- HDC hdcMem = CreateCompatibleDC(hdc);
- HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), nullptr);
- HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcMem, hBmpOsb);
- SetBkMode(hdcMem, TRANSPARENT);
-
- HBRUSH hBrush = CreateSolidBrush(bkColour);
- HBRUSH hoBrush = (HBRUSH)SelectObject(hdcMem, hBrush);
- FillRect(hdcMem, rcPaint, hBrush);
- SelectObject(hdcMem, hoBrush);
- DeleteObject(hBrush);
- if (hBmpBackground) {
- BITMAP bmp;
- GetObject(hBmpBackground, sizeof(bmp), &bmp);
-
- HDC hdcBmp = CreateCompatibleDC(hdcMem);
- SelectObject(hdcBmp, hBmpBackground);
- int y = backgroundBmpUse & CLBF_SCROLL ? -yScroll : 0;
- int maxx = backgroundBmpUse & CLBF_TILEH ? clRect.right : 1;
- int maxy = backgroundBmpUse & CLBF_TILEV ? rcPaint->bottom : y+1;
-
- int destw, desth;
- switch(backgroundBmpUse & CLBM_TYPE) {
- case CLB_STRETCH:
- if (backgroundBmpUse & CLBF_PROPORTIONAL) {
- if (clRect.right * bmp.bmHeight < clRect.bottom * bmp.bmWidth) {
- desth = clRect.bottom;
- destw = desth * bmp.bmWidth/bmp.bmHeight;
- }
- else {
- destw = clRect.right;
- desth = destw * bmp.bmHeight/bmp.bmWidth;
- }
- }
- else {
- destw = clRect.right;
- desth = clRect.bottom;
- }
- break;
- case CLB_STRETCHH:
- if (backgroundBmpUse & CLBF_PROPORTIONAL) {
- destw = clRect.right;
- desth = destw * bmp.bmHeight/bmp.bmWidth;
- if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT)
- desth = g_ctrl->nButtonHeight+2;
- }
- else {
- destw = clRect.right;
- desth = bmp.bmHeight;
- }
- break;
- case CLB_STRETCHV:
- if (backgroundBmpUse & CLBF_PROPORTIONAL) {
- desth = clRect.bottom;
- destw = desth*bmp.bmWidth/bmp.bmHeight;
- }
- else {
- destw = bmp.bmWidth;
- desth = clRect.bottom;
- }
- break;
- default: //clb_topleft
- destw = bmp.bmWidth;
- desth = bmp.bmHeight;
- if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT)
- desth = g_ctrl->nButtonHeight+2;
- break;
- }
-
- for (; y < maxy; y += desth) {
- if (y < rcPaint->top - desth)
- continue;
-
- for (int x = 0; x < maxx; x += destw)
- StretchBlt(hdcMem, x, y, destw, desth, hdcBmp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
- }
- DeleteDC(hdcBmp);
- }
- BitBlt(hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, hdcMem, rcPaint->left, rcPaint->top, SRCCOPY);
- SelectObject(hdcMem, hOldBmp);
- DeleteDC(hdcMem);
- DeleteObject(hBmpOsb);
-
- paintst.fErase = FALSE;
- EndPaint(hwnd, &paintst);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- static bool supressRepos = false;
-
- switch(msg) {
- case WM_CREATE:
- g_ctrl->hWnd = hwnd;
- PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0);
- return FALSE;
-
- case WM_DESTROY:
- g_ctrl->hWnd = nullptr;
- break;
-
- case WM_MOVE:
- return 0;
-
- case WM_WINDOWPOSCHANGING:
- case WM_SIZE:
- if (g_ctrl->nLastHeight != HIWORD(lParam)) {
- db_set_dw(0, TTB_OPTDIR, "LastHeight", g_ctrl->nLastHeight = HIWORD(lParam));
- ArrangeButtons();
- }
- if (supressRepos) {
- supressRepos = false;
- break;
- }
- __fallthrough;
-
- case TTB_REPOSBUTTONS:
- if (g_ctrl->hWnd == hwnd) {
- int iHeight = ArrangeButtons();
- if ( g_ctrl->bAutoSize) {
- RECT rcClient;
- GetClientRect(g_ctrl->hWnd, &rcClient);
- rcClient.bottom -= rcClient.top;
- if (rcClient.bottom != iHeight && iHeight && rcClient.bottom) {
- supressRepos = true;
- PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0);
- }
- }
- return 0;
- }
- break;
-
- case WM_NCPAINT:
- case WM_PAINT:
- PaintToolbar(hwnd);
- return 0;
-
- case WM_LBUTTONDOWN:
- if (db_get_b(NULL, "CLUI", "ClientAreaDrag", 0)) {
- POINT pt;
- GetCursorPos(&pt);
- return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y));
- }
- return 0;
-
- case WM_COMMAND:
- switch (HIWORD(wParam)) {
- case BN_CLICKED:
- case BN_DOUBLECLICKED:
- {
- int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA);
- if (id != 0) {
- mir_cslock lck(csButtonsHook);
- TopButtonInt* b = idtopos(id);
- if (b == nullptr || b->isSep())
- return 0;
-
- if (b->dwFlags & TTBBF_ASPUSHBUTTON)
- b->bPushed = !b->bPushed;
-
- if (b->bPushed) { //Dn -> Up
- if (!(b->dwFlags & TTBBF_ISLBUTTON)) // must be always true
- if (b->pszService != nullptr)
- CallService(b->pszService, b->wParamUp, b->lParamUp);
- }
- else { //Up -> Dn
- if (b->pszService != nullptr)
- CallService(b->pszService, b->wParamDown, b->lParamDown);
- }
-
- b->SetBitmap();
- }
- }
- break;
- }
- break;
-
- case TTB_UPDATEFRAMEVISIBILITY:
- {
- bool bResize = false;
-
- if (g_ctrl->bAutoSize) {
- int Height = ArrangeButtons();
- INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), 0);
- if (Height != 0 && Height != frameopt) {
- CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), Height);
- bResize = TRUE;
- }
- }
-
- if (g_ctrl->bOrderChanged)
- bResize = TRUE, g_ctrl->bOrderChanged = FALSE;
-
- if (bResize)
- CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)g_ctrl->hFrame, FU_FMPOS);
- }
- break;
-
- case TTB_SETCUSTOMDATASIZE:
- g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, lParam);
- if (lParam > sizeof(TTBCtrl))
- memset(g_ctrl+1, 0, lParam - sizeof(TTBCtrl));
-
- SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl);
- break;
-
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return TRUE;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CALLBACK OnEventFire()
-{
- HWND parent = pcli->hwndContactList;
- if (parent == nullptr) // no clist, no buttons
- return;
-
- WNDCLASS wndclass = {0};
- wndclass.lpfnWndProc = TopToolBarProc;
- wndclass.cbWndExtra = sizeof(void *);
- wndclass.hInstance = hInst;
- wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
- wndclass.lpszClassName = pluginname;
- RegisterClass(&wndclass);
-
- g_ctrl->pButtonList = (SortedList *)&Buttons;
- g_ctrl->hWnd = CreateWindow(pluginname, L"Toolbar",
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
- 0, 0, 0, g_ctrl->nLastHeight, parent, nullptr, hInst, nullptr);
- SetWindowLongPtr(g_ctrl->hWnd, 0, (LONG_PTR)g_ctrl);
-
- LoadBackgroundOptions();
- LoadAllSeparators();
LoadAllLButs();
-
- // if we're working in skinned clist, receive the standard buttons & customizations
- if (g_CustomProc && g_ctrl->hWnd)
- g_CustomProc(TTB_WINDOW_HANDLE, g_ctrl->hWnd, g_CustomProcParam);
- else
- InitInternalButtons();
-
- // if there's no customized frames, create our own
- if (g_ctrl->hFrame == nullptr) {
- CLISTFrame Frame = { sizeof(Frame) };
- Frame.tname = L"Toolbar";
- Frame.hWnd = g_ctrl->hWnd;
- Frame.align = alTop;
- Frame.Flags = F_VISIBLE | F_NOBORDER | F_LOCKED | F_UNICODE;
- Frame.height = g_ctrl->nLastHeight;
- Frame.hIcon = Skin_LoadIcon(SKINICON_OTHER_FRAME);
- g_ctrl->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0);
- }
-
- // receive buttons
- NotifyEventHooks(hTTBModuleLoaded, 0, 0);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-int LoadBackgroundOptions()
-{
- bkColour = db_get_dw(NULL, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR);
- if (hBmpBackground) {
- DeleteObject(hBmpBackground);
- hBmpBackground = nullptr;
- }
-
- if (db_get_b(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) {
- ptrW tszBitmapName(db_get_wsa(NULL, TTB_OPTDIR, "BkBitmap"));
- if (tszBitmapName != NULL)
- hBmpBackground = Bitmap_Load(tszBitmapName);
- }
- backgroundBmpUse = db_get_w(NULL, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE);
-
- RECT rc;
- GetClientRect(g_ctrl->hWnd, &rc);
- InvalidateRect(g_ctrl->hWnd, &rc, TRUE);
- UpdateWindow(g_ctrl->hWnd);
- return 0;
-}
+ +#include "stdafx.h" + +COLORREF bkColour; +HBITMAP hBmpBackground; +int backgroundBmpUse; + +static wchar_t pluginname[] = L"TopToolBar"; + +///////////////////////////////////////////////////////////////////////////////////////// +// Toolbar window procedure + +static void PaintToolbar(HWND hwnd) +{ + InvalidateRect(hwnd, nullptr, FALSE); + + PAINTSTRUCT paintst; + HDC hdc = BeginPaint(hwnd, &paintst); + RECT *rcPaint = &paintst.rcPaint; + + RECT clRect; + GetClientRect(hwnd, &clRect); + + int yScroll = 0; + + HDC hdcMem = CreateCompatibleDC(hdc); + HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), nullptr); + HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcMem, hBmpOsb); + SetBkMode(hdcMem, TRANSPARENT); + + HBRUSH hBrush = CreateSolidBrush(bkColour); + HBRUSH hoBrush = (HBRUSH)SelectObject(hdcMem, hBrush); + FillRect(hdcMem, rcPaint, hBrush); + SelectObject(hdcMem, hoBrush); + DeleteObject(hBrush); + if (hBmpBackground) { + BITMAP bmp; + GetObject(hBmpBackground, sizeof(bmp), &bmp); + + HDC hdcBmp = CreateCompatibleDC(hdcMem); + SelectObject(hdcBmp, hBmpBackground); + int y = backgroundBmpUse & CLBF_SCROLL ? -yScroll : 0; + int maxx = backgroundBmpUse & CLBF_TILEH ? clRect.right : 1; + int maxy = backgroundBmpUse & CLBF_TILEV ? rcPaint->bottom : y+1; + + int destw, desth; + switch(backgroundBmpUse & CLBM_TYPE) { + case CLB_STRETCH: + if (backgroundBmpUse & CLBF_PROPORTIONAL) { + if (clRect.right * bmp.bmHeight < clRect.bottom * bmp.bmWidth) { + desth = clRect.bottom; + destw = desth * bmp.bmWidth/bmp.bmHeight; + } + else { + destw = clRect.right; + desth = destw * bmp.bmHeight/bmp.bmWidth; + } + } + else { + destw = clRect.right; + desth = clRect.bottom; + } + break; + case CLB_STRETCHH: + if (backgroundBmpUse & CLBF_PROPORTIONAL) { + destw = clRect.right; + desth = destw * bmp.bmHeight/bmp.bmWidth; + if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT) + desth = g_ctrl->nButtonHeight+2; + } + else { + destw = clRect.right; + desth = bmp.bmHeight; + } + break; + case CLB_STRETCHV: + if (backgroundBmpUse & CLBF_PROPORTIONAL) { + desth = clRect.bottom; + destw = desth*bmp.bmWidth/bmp.bmHeight; + } + else { + destw = bmp.bmWidth; + desth = clRect.bottom; + } + break; + default: //clb_topleft + destw = bmp.bmWidth; + desth = bmp.bmHeight; + if (backgroundBmpUse & CLBF_TILEVTOROWHEIGHT) + desth = g_ctrl->nButtonHeight+2; + break; + } + + for (; y < maxy; y += desth) { + if (y < rcPaint->top - desth) + continue; + + for (int x = 0; x < maxx; x += destw) + StretchBlt(hdcMem, x, y, destw, desth, hdcBmp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); + } + DeleteDC(hdcBmp); + } + BitBlt(hdc, rcPaint->left, rcPaint->top, rcPaint->right-rcPaint->left, rcPaint->bottom-rcPaint->top, hdcMem, rcPaint->left, rcPaint->top, SRCCOPY); + SelectObject(hdcMem, hOldBmp); + DeleteDC(hdcMem); + DeleteObject(hBmpOsb); + + paintst.fErase = FALSE; + EndPaint(hwnd, &paintst); +} + +///////////////////////////////////////////////////////////////////////////////////////// + +LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static bool supressRepos = false; + + switch(msg) { + case WM_CREATE: + g_ctrl->hWnd = hwnd; + PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0); + return FALSE; + + case WM_DESTROY: + g_ctrl->hWnd = nullptr; + break; + + case WM_MOVE: + return 0; + + case WM_WINDOWPOSCHANGING: + case WM_SIZE: + if (g_ctrl->nLastHeight != HIWORD(lParam)) { + db_set_dw(0, TTB_OPTDIR, "LastHeight", g_ctrl->nLastHeight = HIWORD(lParam)); + ArrangeButtons(); + } + if (supressRepos) { + supressRepos = false; + break; + } + __fallthrough; + + case TTB_REPOSBUTTONS: + if (g_ctrl->hWnd == hwnd) { + int iHeight = ArrangeButtons(); + if ( g_ctrl->bAutoSize) { + RECT rcClient; + GetClientRect(g_ctrl->hWnd, &rcClient); + rcClient.bottom -= rcClient.top; + if (rcClient.bottom != iHeight && iHeight && rcClient.bottom) { + supressRepos = true; + PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0); + } + } + return 0; + } + break; + + case WM_NCPAINT: + case WM_PAINT: + PaintToolbar(hwnd); + return 0; + + case WM_LBUTTONDOWN: + if (db_get_b(NULL, "CLUI", "ClientAreaDrag", 0)) { + POINT pt; + GetCursorPos(&pt); + return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y)); + } + return 0; + + case WM_COMMAND: + switch (HIWORD(wParam)) { + case BN_CLICKED: + case BN_DOUBLECLICKED: + { + int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA); + if (id != 0) { + mir_cslock lck(csButtonsHook); + TopButtonInt* b = idtopos(id); + if (b == nullptr || b->isSep()) + return 0; + + if (b->dwFlags & TTBBF_ASPUSHBUTTON) + b->bPushed = !b->bPushed; + + if (b->bPushed) { //Dn -> Up + if (!(b->dwFlags & TTBBF_ISLBUTTON)) // must be always true + if (b->pszService != nullptr) + CallService(b->pszService, b->wParamUp, b->lParamUp); + } + else { //Up -> Dn + if (b->pszService != nullptr) + CallService(b->pszService, b->wParamDown, b->lParamDown); + } + + b->SetBitmap(); + } + } + break; + } + break; + + case TTB_UPDATEFRAMEVISIBILITY: + { + bool bResize = false; + + if (g_ctrl->bAutoSize) { + int Height = ArrangeButtons(); + INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), 0); + if (Height != 0 && Height != frameopt) { + CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), Height); + bResize = TRUE; + } + } + + if (g_ctrl->bOrderChanged) + bResize = TRUE, g_ctrl->bOrderChanged = FALSE; + + if (bResize) + CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)g_ctrl->hFrame, FU_FMPOS); + } + break; + + case TTB_SETCUSTOMDATASIZE: + g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, lParam); + if (lParam > sizeof(TTBCtrl)) + memset(g_ctrl+1, 0, lParam - sizeof(TTBCtrl)); + + SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl); + break; + + default: + return DefWindowProc(hwnd, msg, wParam, lParam); + } + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +void CALLBACK OnEventFire() +{ + HWND parent = pcli->hwndContactList; + if (parent == nullptr) // no clist, no buttons + return; + + WNDCLASS wndclass = {0}; + wndclass.lpfnWndProc = TopToolBarProc; + wndclass.cbWndExtra = sizeof(void *); + wndclass.hInstance = g_plugin.getInst(); + wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wndclass.lpszClassName = pluginname; + RegisterClass(&wndclass); + + g_ctrl->pButtonList = (SortedList *)&Buttons; + g_ctrl->hWnd = CreateWindow(pluginname, L"Toolbar", + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + 0, 0, 0, g_ctrl->nLastHeight, parent, nullptr, g_plugin.getInst(), nullptr); + SetWindowLongPtr(g_ctrl->hWnd, 0, (LONG_PTR)g_ctrl); + + LoadBackgroundOptions(); + LoadAllSeparators(); + LoadAllLButs(); + + // if we're working in skinned clist, receive the standard buttons & customizations + if (g_CustomProc && g_ctrl->hWnd) + g_CustomProc(TTB_WINDOW_HANDLE, g_ctrl->hWnd, g_CustomProcParam); + else + InitInternalButtons(); + + // if there's no customized frames, create our own + if (g_ctrl->hFrame == nullptr) { + CLISTFrame Frame = { sizeof(Frame) }; + Frame.tname = L"Toolbar"; + Frame.hWnd = g_ctrl->hWnd; + Frame.align = alTop; + Frame.Flags = F_VISIBLE | F_NOBORDER | F_LOCKED | F_UNICODE; + Frame.height = g_ctrl->nLastHeight; + Frame.hIcon = Skin_LoadIcon(SKINICON_OTHER_FRAME); + g_ctrl->hFrame = (HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); + } + + // receive buttons + NotifyEventHooks(hTTBModuleLoaded, 0, 0); +} + +///////////////////////////////////////////////////////////////////////////////////////// + +int LoadBackgroundOptions() +{ + bkColour = db_get_dw(NULL, TTB_OPTDIR, "BkColour", TTBDEFAULT_BKCOLOUR); + if (hBmpBackground) { + DeleteObject(hBmpBackground); + hBmpBackground = nullptr; + } + + if (db_get_b(NULL, TTB_OPTDIR, "UseBitmap", TTBDEFAULT_USEBITMAP)) { + ptrW tszBitmapName(db_get_wsa(NULL, TTB_OPTDIR, "BkBitmap")); + if (tszBitmapName != NULL) + hBmpBackground = Bitmap_Load(tszBitmapName); + } + backgroundBmpUse = db_get_w(NULL, TTB_OPTDIR, "BkBmpUse", TTBDEFAULT_BKBMPUSE); + + RECT rc; + GetClientRect(g_ctrl->hWnd, &rc); + InvalidateRect(g_ctrl->hWnd, &rc, TRUE); + UpdateWindow(g_ctrl->hWnd); + return 0; +} diff --git a/plugins/TopToolBar/src/topbutton.cpp b/plugins/TopToolBar/src/topbutton.cpp index b16bdd84f7..f9bf74a0fc 100644 --- a/plugins/TopToolBar/src/topbutton.cpp +++ b/plugins/TopToolBar/src/topbutton.cpp @@ -53,7 +53,7 @@ DWORD TopButtonInt::CheckFlags(DWORD Flags) void TopButtonInt::CreateWnd()
{
if (!(dwFlags & TTBBF_ISSEPARATOR)) {
- hwnd = CreateWindow(TTB_BUTTON_CLASS, L"", BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP | SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, nullptr, hInst, this);
+ hwnd = CreateWindow(TTB_BUTTON_CLASS, L"", BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP | SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, nullptr, g_plugin.getInst(), this);
if (dwFlags & TTBBF_ASPUSHBUTTON)
SendMessage(hwnd, BUTTONSETASPUSHBTN, 1, 0);
@@ -65,7 +65,7 @@ void TopButtonInt::CreateWnd() }
// maybe SEPWIDTH, not g_ctrl->nButtonWidth?
else
- hwnd = CreateWindow(L"STATIC", L"", WS_CHILD | SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, nullptr, hInst, nullptr);
+ hwnd = CreateWindow(L"STATIC", L"", WS_CHILD | SS_NOTIFY, 0, 0, g_ctrl->nButtonWidth, g_ctrl->nButtonHeight, g_ctrl->hWnd, nullptr, g_plugin.getInst(), nullptr);
SetWindowLongPtr(hwnd, GWLP_USERDATA, id);
SetBitmap();
diff --git a/plugins/TopToolBar/src/ttbopt.cpp b/plugins/TopToolBar/src/ttbopt.cpp index 27d1b36b2a..8c416d7200 100644 --- a/plugins/TopToolBar/src/ttbopt.cpp +++ b/plugins/TopToolBar/src/ttbopt.cpp @@ -276,7 +276,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (!(btn->dwFlags & TTBBF_OPTIONAL)) {
// create button
TTBButton ttb = {};
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.hIconDn = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
ttb.name = nullptr;
ttb.program = nullptr;
@@ -304,7 +304,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (ctrlid == IDC_ADDLBUTTON) {
// create button
TTBButton ttb = {};
- ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ ttb.hIconDn = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL;
ttb.name = LPGEN("Default");
ttb.program = L"Execute Path";
@@ -541,7 +541,7 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR int TTBOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.szGroup.a = LPGEN("Contact list");
odp.position = -1000000000;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_BUTORDER);
diff --git a/plugins/WebView/src/main.cpp b/plugins/WebView/src/main.cpp index 303a58a03b..a5041f21c0 100644 --- a/plugins/WebView/src/main.cpp +++ b/plugins/WebView/src/main.cpp @@ -27,10 +27,15 @@ MWindowList hWindowList; HNETLIBUSER hNetlibUser;
HANDLE hHookDisplayDataAlert, hHookAlertPopup, hHookAlertWPopup, hHookErrorPopup, hHookAlertOSD;
-int hLangpack = 0;
+int hLangpack;
+CMPlugin g_plugin;
+
static HMODULE hRichEd = nullptr;
-PLUGININFOEX pluginInfoEx = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfoEx =
+{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -86,10 +91,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC /////////////////////////////////////////////////////////////////////////////////////////
-CMPlugin g_plugin;
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
extern "C" int __declspec(dllexport) Load()
{
mir_getLP(&pluginInfoEx);
diff --git a/plugins/WebView/src/stdafx.h b/plugins/WebView/src/stdafx.h index b214d3d6ea..3ce8c77b06 100644 --- a/plugins/WebView/src/stdafx.h +++ b/plugins/WebView/src/stdafx.h @@ -14,7 +14,6 @@ #include <time.h>
#include <wchar.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_system.h>
#include <m_clist.h>
diff --git a/plugins/WebView/src/webview.h b/plugins/WebView/src/webview.h index ced8d87a81..ee7d9ce62c 100644 --- a/plugins/WebView/src/webview.h +++ b/plugins/WebView/src/webview.h @@ -253,4 +253,3 @@ struct CMPlugin : public PLUGIN<CMPlugin> SetUniqueId("PreserveName");
}
};
-
|