summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-17 19:41:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-17 19:41:35 +0300
commit11e70d8c4e224d80015fffe0378c53abee5fd824 (patch)
tree8b21511f57aad4a9aaaa9391450cf5b83146a2f8 /plugins/SendScreenshotPlus/src
parent0c12fe889baeced3e7d8c3f2558d10f563a43612 (diff)
Popup, PManagerEx, QuickContacts, RemovePersonalSettings, Restart, SeenPlugin, SendSS, ShlExt, SimpleAR, SimpleStatusMsg, SkypeStatusChange, SmileyAdd, SMS => CMPlugin
Diffstat (limited to 'plugins/SendScreenshotPlus/src')
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/Main.cpp53
-rw-r--r--plugins/SendScreenshotPlus/src/Main.h38
-rw-r--r--plugins/SendScreenshotPlus/src/UAboutForm.cpp14
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.cpp10
-rw-r--r--plugins/SendScreenshotPlus/src/ctrl_button.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/dlg_msgbox.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/stdafx.h9
8 files changed, 50 insertions, 80 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index f985aec6f4..2945dce91e 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -419,7 +419,7 @@ void CSend::Exit(unsigned int Result)
switch (Result) {
case CSEND_DIALOG:
Skin_PlaySound("FileDone");
- DialogBoxParam(g_hSendSS, MAKEINTRESOURCE(IDD_UResultForm), nullptr, ResultDialogProc, (LPARAM)this);
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UResultForm), nullptr, ResultDialogProc, (LPARAM)this);
err = false;
break;
case ACKRESULT_SUCCESS:
diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp
index c7f583cc50..6f34b5c0d8 100644
--- a/plugins/SendScreenshotPlus/src/Main.cpp
+++ b/plugins/SendScreenshotPlus/src/Main.cpp
@@ -27,14 +27,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
-#include "Main.h"
// Prototypes ///////////////////////////////////////////////////////////////////////////
-CHAT_MANAGER *pci;
-HINSTANCE g_hSendSS;
+
+int hLangpack;
+CMPlugin g_plugin;
+CHAT_MANAGER *pci;
+
MGLOBAL g_myGlobals;
-HNETLIBUSER g_hNetlibUser=nullptr;//!< Netlib Register User
-int hLangpack;//Miranda NG langpack used by translate functions, filled by mir_getLP()
+HNETLIBUSER g_hNetlibUser;
IconItem ICONS[ICO_END_] =
{
@@ -57,7 +58,6 @@ IconItem ICONS_BTN[ICO_BTN_END_] =
{ LPGEN("Update"), "update", IDI_UPDATE },
{ LPGEN("OK"), "ok", IDI_OK },
{ LPGEN("Cancel"), "cancel", IDI_CANCEL },
- // {LPGEN("Apply"),"apply",IDI_APPLY},
{ LPGEN("Edit"), "edit", IDI_EDIT },
{ LPGEN("Edit on"), "editon", IDI_EDITON },
{ LPGEN("Copy"), "copy", IDI_COPY },
@@ -207,13 +207,10 @@ INT_PTR service_Send2ImageShack(WPARAM wParam, LPARAM lParam)
return (INT_PTR)result;
}
-// Functions ////////////////////////////////////////////////////////////////////////////
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static PLUGININFOEX pluginInfo =
{
- g_hSendSS = hinstDLL;
- return TRUE;
-}
-static const PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -225,11 +222,15 @@ static const PLUGININFOEX pluginInfo = {
// {ED39AF7C-BECD-404E-9499-4D04F711B9CB}
{ 0xed39af7c, 0xbecd, 0x404e, { 0x94, 0x99, 0x4d, 0x04, 0xf7, 0x11, 0xb9, 0xcb } }
};
-DLL_EXPORT PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
- return const_cast<PLUGININFOEX*>(&pluginInfo);
+ return &pluginInfo;
}
-/// hooks
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// hooks
+
int hook_ModulesLoaded(WPARAM, LPARAM)
{
g_myGlobals.PopupExist = ServiceExists(MS_POPUP_ADDPOPUPT);
@@ -250,6 +251,7 @@ int hook_ModulesLoaded(WPARAM, LPARAM)
PROFILE_PATHW L"\\" CURRENT_PROFILEW L"\\Screenshots");
return 0;
}
+
int hook_SystemPreShutdown(WPARAM, LPARAM)
{
TfrmAbout::Unload();//crashes if done from "Unload" because of dependencies
@@ -262,7 +264,8 @@ int hook_SystemPreShutdown(WPARAM, LPARAM)
}
ATOM g_clsTargetHighlighter = 0;
-DLL_EXPORT int Load(void)
+
+extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfo);
pci = Chat_GetInterface();
@@ -272,8 +275,8 @@ DLL_EXPORT int Load(void)
HookEvent(ME_SYSTEM_PRESHUTDOWN, hook_SystemPreShutdown);
/// icons
- Icon_Register(g_hSendSS, SZ_SENDSS, ICONS, sizeof(ICONS) / sizeof(IconItem), SZ_SENDSS);
- Icon_Register(g_hSendSS, SZ_SENDSS "/" LPGEN("Buttons"), ICONS_BTN, sizeof(ICONS_BTN) / sizeof(IconItem), SZ_SENDSS);
+ Icon_Register(g_plugin.getInst(), SZ_SENDSS, ICONS, sizeof(ICONS) / sizeof(IconItem), SZ_SENDSS);
+ Icon_Register(g_plugin.getInst(), SZ_SENDSS "/" LPGEN("Buttons"), ICONS_BTN, sizeof(ICONS_BTN) / sizeof(IconItem), SZ_SENDSS);
/// services
#define srv_reg(name) do{\
@@ -320,17 +323,17 @@ DLL_EXPORT int Load(void)
/// register highlighter window class
HBRUSH brush = CreateSolidBrush(0x0000FF00);//owned by class
- WNDCLASS wndclass = { CS_HREDRAW | CS_VREDRAW, DefWindowProc, 0, 0, g_hSendSS, nullptr, nullptr, brush, nullptr, L"SendSSHighlighter" };
+ WNDCLASS wndclass = { CS_HREDRAW | CS_VREDRAW, DefWindowProc, 0, 0, g_plugin.getInst(), nullptr, nullptr, brush, nullptr, L"SendSSHighlighter" };
g_clsTargetHighlighter = RegisterClass(&wndclass);
return 0;
}
-/*---------------------------------------------------------------------------
-* Prepare the plugin to stop
-* Called by Miranda when it will exit or when the plugin gets deselected
-*/
-DLL_EXPORT int Unload(void)
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Prepare the plugin to stop
+
+extern "C" __declspec(dllexport) int Unload(void)
{
if (g_clsTargetHighlighter)
- UnregisterClass((wchar_t*)g_clsTargetHighlighter, g_hSendSS), g_clsTargetHighlighter = 0;
+ UnregisterClass((wchar_t*)g_clsTargetHighlighter, g_plugin.getInst()), g_clsTargetHighlighter = 0;
return 0;
}
diff --git a/plugins/SendScreenshotPlus/src/Main.h b/plugins/SendScreenshotPlus/src/Main.h
deleted file mode 100644
index c9954e237e..0000000000
--- a/plugins/SendScreenshotPlus/src/Main.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org),
-Copyright (c) 2000-09 Miranda ICQ/IM project,
-
-This file is part of Send Screenshot Plus, a Miranda IM plugin.
-Copyright (c) 2010 Ing.U.Horn
-
-Parts of this file based on original sorce code
-(c) 2004-2006 Sérgio Vieira Rolanski (portet from Borland C++)
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#ifndef MainH
-#define MainH
-
-#define DLL_EXPORT __declspec(dllexport)
-extern "C"{
-DLL_EXPORT PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion);
-DLL_EXPORT int Load(void);
-DLL_EXPORT int Unload(void);
-}
-#endif
diff --git a/plugins/SendScreenshotPlus/src/UAboutForm.cpp b/plugins/SendScreenshotPlus/src/UAboutForm.cpp
index 6c135e55a4..eda56157eb 100644
--- a/plugins/SendScreenshotPlus/src/UAboutForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UAboutForm.cpp
@@ -98,10 +98,10 @@ LRESULT TfrmAbout::wmInitdialog(WPARAM, LPARAM)
CMStringW pszText(_A2W(__COPYRIGHT));
pszText.Append(L"\r\n\r\n");
- HRSRC hRes = FindResource(g_hSendSS, MAKEINTRESOURCE(IDR_LICENSE), L"TEXT");
- DWORD size = SizeofResource(g_hSendSS, hRes);
+ HRSRC hRes = FindResource(g_plugin.getInst(), MAKEINTRESOURCE(IDR_LICENSE), L"TEXT");
+ DWORD size = SizeofResource(g_plugin.getInst(), hRes);
char* data = (char*)mir_alloc(size + 1);
- memcpy(data, LockResource(LoadResource(g_hSendSS, hRes)), size);
+ memcpy(data, LockResource(LoadResource(g_plugin.getInst(), hRes)), size);
data[size] = '\0';
pszText.AppendFormat(L"%S", data);
mir_free(data);
@@ -110,10 +110,10 @@ LRESULT TfrmAbout::wmInitdialog(WPARAM, LPARAM)
// Credit
{
- HRSRC hRes = FindResource(g_hSendSS, MAKEINTRESOURCE(IDR_CREDIT), L"TEXT");
- DWORD size = SizeofResource(g_hSendSS, hRes);
+ HRSRC hRes = FindResource(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CREDIT), L"TEXT");
+ DWORD size = SizeofResource(g_plugin.getInst(), hRes);
char* data = (char*)mir_alloc(size + 1);
- memcpy(data, LockResource(LoadResource(g_hSendSS, hRes)), size);
+ memcpy(data, LockResource(LoadResource(g_plugin.getInst(), hRes)), size);
data[size] = '\0';
wchar_t* pszText = mir_a2u(data);
mir_free(data);
@@ -171,7 +171,7 @@ TfrmAbout::TfrmAbout(HWND Owner)
m_hWndOwner = Owner;
m_Page = 1;
// create window
- m_hWnd = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UAboutForm), nullptr, DlgTfrmAbout, (LPARAM)this);
+ m_hWnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UAboutForm), nullptr, DlgTfrmAbout, (LPARAM)this);
//register object
_HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this));
}
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp
index 6430995360..145de2c080 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp
@@ -224,7 +224,7 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM)
/// Add a tab for each of the three child dialog boxes.
itab.tcih.pszText = TranslateT("Window");
itab.tcih.iImage = 0;
- itab.hwndTabPage = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UMain_CaptureWindow), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureWindow);
+ itab.hwndTabPage = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMain_CaptureWindow), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureWindow);
TabCtrl_InsertItem(m_hwndTab, 0, &itab);
/// get tab boundaries (required after 1st tab)
GetClientRect(m_hwndTab, &rcTab);
@@ -238,7 +238,7 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM)
itab.tcih.pszText = TranslateT("Desktop");
itab.tcih.iImage = 1;
- itab.hwndTabPage = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UMain_CaptureDesktop), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureDesktop);
+ itab.hwndTabPage = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMain_CaptureDesktop), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureDesktop);
TabCtrl_InsertItem(m_hwndTab, 1, &itab);
SetWindowPos(itab.hwndTabPage, HWND_TOP, rcTab.left, rcTab.top, rcTab.right, rcTab.bottom, 0);
@@ -261,7 +261,7 @@ void TfrmMain::wmInitdialog(WPARAM, LPARAM)
itab.tcih.pszText = TranslateT("File");
itab.tcih.iImage = 2;
- itab.hwndTabPage = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UMain_CaptureFile), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureFile);
+ itab.hwndTabPage = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMain_CaptureFile), m_hWnd, DlgProc_CaptureTabPage, IDD_UMain_CaptureFile);
TabCtrl_InsertItem(m_hwndTab, 2, &itab);
SetWindowPos(itab.hwndTabPage, HWND_TOP, rcTab.left, rcTab.top, rcTab.right, rcTab.bottom, 0);
@@ -535,7 +535,7 @@ void TfrmMain::wmTimer(WPARAM wParam, LPARAM)
static int primarymouse;
if (!m_hTargetHighlighter) {
primarymouse = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON;
- m_hTargetHighlighter = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, (wchar_t*)g_clsTargetHighlighter, nullptr, WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, g_hSendSS, nullptr);
+ m_hTargetHighlighter = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, (wchar_t*)g_clsTargetHighlighter, nullptr, WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, g_plugin.getInst(), nullptr);
if (!m_hTargetHighlighter) return;
SetLayeredWindowAttributes(m_hTargetHighlighter, 0, 123, LWA_ALPHA);
SetSystemCursor(CopyCursor(GetIcon(ICO_TARGET)), OCR_IBEAM);//text cursor
@@ -808,7 +808,7 @@ void TfrmMain::Init(wchar_t* DestFolder, MCONTACT Contact)
m_hContact = Contact;
// create window
- m_hWnd = CreateDialogParam(g_hSendSS, MAKEINTRESOURCE(IDD_UMainForm), nullptr, DlgTfrmMain, (LPARAM)this);
+ m_hWnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_UMainForm), nullptr, DlgTfrmMain, (LPARAM)this);
//register object
_HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this));
diff --git a/plugins/SendScreenshotPlus/src/ctrl_button.cpp b/plugins/SendScreenshotPlus/src/ctrl_button.cpp
index 837b792580..37f965e87f 100644
--- a/plugins/SendScreenshotPlus/src/ctrl_button.cpp
+++ b/plugins/SendScreenshotPlus/src/ctrl_button.cpp
@@ -653,7 +653,7 @@ void CtrlButtonUnloadModule()
{
if (!g_init) return;
g_init = false;
- UnregisterClass(UINFOBUTTONCLASS, g_hSendSS);
+ UnregisterClass(UINFOBUTTONCLASS, g_plugin.getInst());
}
void CtrlButtonLoadModule()/// @fixme : compatibility with UInfoEx is everything but perfect... we get a huge problem if UInfoEx is unloaded...
diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp
index fb0d7f9eec..e0a4be0666 100644
--- a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp
+++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/// SendSS compatibility:
#include "stdafx.h"
-#define ghInst g_hSendSS
+#define ghInst g_plugin.getInst()
#define myGlobals g_myGlobals
#define MODNAME SZ_SENDSS
#define ICO_COMMON_MAIN 0xFFFF
diff --git a/plugins/SendScreenshotPlus/src/stdafx.h b/plugins/SendScreenshotPlus/src/stdafx.h
index 2187b01fa7..6d37f1d4ae 100644
--- a/plugins/SendScreenshotPlus/src/stdafx.h
+++ b/plugins/SendScreenshotPlus/src/stdafx.h
@@ -52,7 +52,6 @@ using namespace std;
#include <msapi/vsstyle.h>
#include <msapi/vssym32.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_button.h>
#include <m_chat_int.h>
@@ -119,8 +118,14 @@ typedef struct _MGLOBAL {
// Miranda Database Key
#define SZ_SENDSS "SendSS"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(SZ_SENDSS)
+ {}
+};
+
extern ATOM g_clsTargetHighlighter;
-extern HINSTANCE g_hSendSS;
extern MGLOBAL g_myGlobals;
extern HNETLIBUSER g_hNetlibUser;