summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/SendScreenshotPlus/src/Main.cpp71
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.cpp23
-rw-r--r--plugins/SendScreenshotPlus/src/UMainForm.h2
-rw-r--r--plugins/SendScreenshotPlus/src/ctrl_button.cpp22
-rw-r--r--plugins/SendScreenshotPlus/src/ctrl_button.h60
-rw-r--r--plugins/SendScreenshotPlus/src/dlg_msgbox.cpp8
-rw-r--r--plugins/SendScreenshotPlus/src/dlg_msgbox.h2
7 files changed, 94 insertions, 94 deletions
diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp
index 8a24201943..8f075e2af1 100644
--- a/plugins/SendScreenshotPlus/src/Main.cpp
+++ b/plugins/SendScreenshotPlus/src/Main.cpp
@@ -104,8 +104,9 @@ extern "C" __declspec(dllexport) int Load(void)
g_hookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED, hook_ModulesLoaded);
g_hookSystemPreShutdown=HookEvent(ME_SYSTEM_PRESHUTDOWN, hook_SystemPreShutdown);
- AddMenuItems();
RegisterServices();
+ AddMenuItems();
+
HBRUSH brush=CreateSolidBrush(0x0000FF00);//owned by class
WNDCLASS wndclass={CS_HREDRAW|CS_VREDRAW,DefWindowProc,0,0,hInst,NULL,NULL,brush,NULL,L"SendSSHighlighter"};
g_clsTargetHighlighter=RegisterClass(&wndclass);
@@ -122,9 +123,8 @@ int hook_ModulesLoaded(WPARAM, LPARAM)
// Netlib register
NetlibInit();
- // load my button class
- if(!ServiceExists("UserInfo/vCard/Export"))
- CtrlButtonLoadModule();
+ // load my button class / or use UInfoEx
+ CtrlButtonLoadModule();
// Folders plugin support
hFolderScreenshot = FoldersRegisterCustomPathT(LPGEN("SendSS"), LPGEN("Screenshots"),
@@ -139,7 +139,7 @@ int hook_ModulesLoaded(WPARAM, LPARAM)
*/
extern "C" __declspec(dllexport) int Unload(void)
-{
+{//as "ghazan" says, it's useless to unregister services or unhook events, let's still do it for now :P
UnRegisterServices();
if(g_hookModulesLoaded) UnhookEvent(g_hookModulesLoaded),g_hookModulesLoaded=0;
if(g_hookSystemPreShutdown) UnhookEvent(g_hookSystemPreShutdown),g_hookSystemPreShutdown=0;
@@ -185,26 +185,27 @@ void NetlibClose(void) {
// wParam = 0
// lParam = anything but 0
INT_PTR service_CaptureAndSendDesktop(WPARAM wParam, LPARAM lParam) {
- TfrmMain *frmMain=new TfrmMain();
- if (!frmMain) {
+ TfrmMain* frmMain=new TfrmMain();
+ if(!frmMain) {
MessageBoxEx(NULL, TranslateT("Could not create main dialog."), TranslateT("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0);
return -1;
}
- LPTSTR pszPath = GetCustomPath();
- if(pszPath)
- {
- HANDLE hContact = (HANDLE) wParam;
- LPSTR pszProto = GetContactProto(hContact);
- bool bChatRoom = db_get_b(hContact, pszProto, "ChatRoom", 0) != 0;
- frmMain->m_opt_chkTimed = false;
- frmMain->m_opt_tabCapture = 1;
- frmMain->m_opt_cboxDesktop = 0;
- frmMain->m_opt_chkEditor = false;
- frmMain->m_opt_cboxSendBy = bChatRoom ? SS_IMAGESHACK:SS_FILESEND;
- frmMain->Init(pszPath, hContact); // this method create the window hidden.
- frmMain->btnCaptureClick(); // this method will call Close()
- mir_free(pszPath);
+ LPTSTR pszPath=GetCustomPath();
+ if(!pszPath){
+ delete frmMain;
+ return -1;
}
+ HANDLE hContact = (HANDLE) wParam;
+ LPSTR pszProto = GetContactProto(hContact);
+ bool bChatRoom = db_get_b(hContact, pszProto, "ChatRoom", 0) != 0;
+ frmMain->m_opt_chkTimed = false;
+ frmMain->m_opt_tabCapture = 1;
+ frmMain->m_opt_cboxDesktop = 0;
+ frmMain->m_opt_chkEditor = false;
+ frmMain->m_opt_cboxSendBy = bChatRoom ? SS_IMAGESHACK:SS_FILESEND;
+ frmMain->Init(pszPath,hContact); // this method create the window hidden.
+ mir_free(pszPath);
+ frmMain->btnCaptureClick(); // this method will call Close()
return 0;
}
@@ -212,19 +213,19 @@ INT_PTR service_CaptureAndSendDesktop(WPARAM wParam, LPARAM lParam) {
// Callback function of service for contact menu and main menu
// wParam = contact handle
// lParam = 0
-INT_PTR service_OpenCaptureDialog(WPARAM wParam, LPARAM lParam) {
- TfrmMain *frmMain=new TfrmMain();
- if (!frmMain) {
+INT_PTR service_OpenCaptureDialog(WPARAM wParam, LPARAM lParam){
+ TfrmMain* frmMain=new TfrmMain();
+ if(!frmMain) {
MessageBoxEx(NULL, TranslateT("Could not create main dialog."), TranslateT("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0);
return -1;
}
-
- LPTSTR pszPath = GetCustomPath();
- if(pszPath)
- {
- frmMain->Init(pszPath, (HANDLE)wParam);
- mir_free(pszPath);
+ LPTSTR pszPath=GetCustomPath();
+ if(!pszPath){
+ delete frmMain;
+ return -1;
}
+ frmMain->Init(pszPath,(HANDLE)wParam);
+ mir_free(pszPath);
frmMain->Show();
return 0;
}
@@ -341,21 +342,19 @@ int UnRegisterServices(){
//---------------------------------------------------------------------------
LPTSTR GetCustomPath() {
LPTSTR pszPath = Utils_ReplaceVarsT(_T("%miranda_userdata%\\Screenshots"));
- if (hFolderScreenshot) {
- TCHAR szPath[1024] = {'\0'};
+ if(hFolderScreenshot){
+ TCHAR szPath[1024]={0};
FoldersGetCustomPathT(hFolderScreenshot, szPath, 1024, pszPath);
mir_freeAndNil(pszPath);
pszPath = mir_tstrdup(szPath);
}
- if(pszPath == NULL)
- {
+ if(!pszPath){
MessageBox(NULL, _T("Can not retrieve Screenshot path."), _T("Send Screenshot"), MB_OK | MB_ICONERROR | MB_APPLMODAL);
return 0;
}
int result = CreateDirectoryTreeT(pszPath);
- if(result != NULL)
- {
+ if(result){
TCHAR szError[MAX_PATH];
mir_sntprintf(szError,MAX_PATH,TranslateT("Could not create Screenshot folder (error code: %d):\n%s\nDo you have write permissions?"),result,pszPath);
MessageBox(NULL, szError, _T("Send Screenshot"), MB_OK | MB_ICONERROR | MB_APPLMODAL);
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp
index ca25f6b163..0acb1fd32d 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.cpp
+++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp
@@ -126,7 +126,7 @@ INT_PTR CALLBACK TfrmMain::DlgProc_CaptureDesktop(HWND hDlg, UINT uMsg, WPARAM w
TfrmMain::CHandleMapping TfrmMain::_HandleMapping;
-LRESULT CALLBACK TfrmMain::DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK TfrmMain::DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC) {
switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) {
@@ -753,20 +753,17 @@ void TfrmMain::SaveOptions(void) {
//---------------------------------------------------------------------------
void TfrmMain::Init(LPTSTR DestFolder, HANDLE Contact) {
- if(DestFolder)
- {
- m_FDestFolder = mir_tstrdup(DestFolder);
- m_hContact = Contact;
- if(!m_hContact) m_opt_cboxSendBy = SS_JUSTSAVE;
+ m_FDestFolder = mir_tstrdup(DestFolder);
+ m_hContact = Contact;
+ if(!m_hContact) m_opt_cboxSendBy = SS_JUSTSAVE;
- // create window
- m_hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UMainForm),0, (DLGPROC)DlgTfrmMain,(LPARAM)this);
- //register object
- _HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this));
+ // create window
+ m_hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UMainForm),0,DlgTfrmMain,(LPARAM)this);
+ //register object
+ _HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this));
- //check Contact
- if(m_cSend) m_cSend->SetContact(Contact);
- }
+ //check Contact
+ if(m_cSend) m_cSend->SetContact(Contact);
}
//---------------------------------------------------------------------------
diff --git a/plugins/SendScreenshotPlus/src/UMainForm.h b/plugins/SendScreenshotPlus/src/UMainForm.h
index 06c513708a..258fba5978 100644
--- a/plugins/SendScreenshotPlus/src/UMainForm.h
+++ b/plugins/SendScreenshotPlus/src/UMainForm.h
@@ -119,7 +119,7 @@ class TfrmMain{
typedef std::map<HWND, TfrmMain *> CHandleMapping;
static CHandleMapping _HandleMapping;
- static LRESULT CALLBACK DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ static INT_PTR CALLBACK DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
void wmInitdialog(WPARAM wParam, LPARAM lParam);
void wmCommand(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/SendScreenshotPlus/src/ctrl_button.cpp b/plugins/SendScreenshotPlus/src/ctrl_button.cpp
index 62154334a5..c127f85334 100644
--- a/plugins/SendScreenshotPlus/src/ctrl_button.cpp
+++ b/plugins/SendScreenshotPlus/src/ctrl_button.cpp
@@ -440,8 +440,8 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L
case WM_PAINT:
{
PAINTSTRUCT ps;
- HDC hdcPaint;
- if (hdcPaint = BeginPaint(hwndBtn, &ps)) {
+ HDC hdcPaint = BeginPaint(hwndBtn, &ps);
+ if (hdcPaint) {
RECT rcClient; GetClientRect(bct->hwnd, &rcClient);
HDC hdcMem = CreateCompatibleDC(hdcPaint);
HBITMAP hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
@@ -616,24 +616,28 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L
}
return DefWindowProc(hwndBtn, uMsg, wParam, lParam);
}
-
-VOID CtrlButtonUnloadModule()
+static bool g_init=false;
+void CtrlButtonUnloadModule()
{
+ if(!g_init) return;
+ g_init=false;
DeleteCriticalSection(&csTips);
UnregisterClass(UINFOBUTTONCLASS, hInst);
}
-VOID CtrlButtonLoadModule()
+void CtrlButtonLoadModule()/// @fixme : compatibility with UInfoEx is everything but perfect... we get a huge problem if UInfoEx is unloaded...
{
+ if(ServiceExists("UserInfo/vCard/Export")) return;
WNDCLASSEX wc;
+ g_init=true;
ZeroMemory(&wc, sizeof(wc));
- wc.cbSize = sizeof(wc);
+ wc.cbSize = sizeof(wc);
wc.lpszClassName = UINFOBUTTONCLASS;
wc.lpfnWndProc = Button_WndProc;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.cbWndExtra = sizeof(LPBTNCTRL);
- wc.style = CS_GLOBALCLASS;
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.cbWndExtra = sizeof(LPBTNCTRL);
+ wc.style = CS_GLOBALCLASS;
RegisterClassEx(&wc);
InitializeCriticalSection(&csTips);
}
diff --git a/plugins/SendScreenshotPlus/src/ctrl_button.h b/plugins/SendScreenshotPlus/src/ctrl_button.h
index 0e4106460d..03bb668aa8 100644
--- a/plugins/SendScreenshotPlus/src/ctrl_button.h
+++ b/plugins/SendScreenshotPlus/src/ctrl_button.h
@@ -1,30 +1,30 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2009 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-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 _UINFOEX_BOTTONS_H_INCLUDED_
-#define _UINFOEX_BOTTONS_H_INCLUDED_ 1
-
-VOID CtrlButtonLoadModule();
-VOID CtrlButtonUnloadModule();
-
-#endif /* _UINFOEX_BOTTONS_H_INCLUDED_ */ \ No newline at end of file
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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 _UINFOEX_BOTTONS_H_INCLUDED_
+#define _UINFOEX_BOTTONS_H_INCLUDED_ 1
+
+void CtrlButtonLoadModule();
+void CtrlButtonUnloadModule();
+
+#endif /* _UINFOEX_BOTTONS_H_INCLUDED_ */
diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp
index 4ada4d76e9..14e1c4d7d9 100644
--- a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp
+++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp
@@ -557,7 +557,7 @@ INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
mir_tcsncpy(pd.lptzText, pMsgBox->ptszMsg, SIZEOF(pd.lptzText));
// CALLBAC Proc
- pd.PluginWindowProc = (WNDPROC)PopupProc;
+ pd.PluginWindowProc = PopupProc;
pd.PluginData = pmpd;
pd.iSeconds = -1;
@@ -648,7 +648,7 @@ INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
*
* @return TRUE, FALSE, IDOK, IDYES, IDALL, IDNO or IDCANCEL
**/
-INT_PTR CALLBACK PopupProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK PopupProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case UM_POPUPACTION:
@@ -712,11 +712,11 @@ INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam)
db_get_b(NULL, MODNAME, SET_POPUPMSGBOX, DEFVAL_POPUPMSGBOX) // user likes popups?
)
{
- rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOXDUMMI), pMsgBox->hParent, (DLGPROC)MsgBoxPop, lParam);
+ rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOXDUMMI), pMsgBox->hParent, MsgBoxPop, lParam);
}
else
{
- rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOX), pMsgBox->hParent, (DLGPROC)MsgBoxProc, lParam);
+ rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOX), pMsgBox->hParent, MsgBoxProc, lParam);
}
}
return rc;
diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.h b/plugins/SendScreenshotPlus/src/dlg_msgbox.h
index 4e9078d966..f878f82adc 100644
--- a/plugins/SendScreenshotPlus/src/dlg_msgbox.h
+++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.h
@@ -90,7 +90,7 @@ typedef struct _MSGBOX
INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK MsgBoxPop (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK PopupProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+LRESULT CALLBACK PopupProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam);
INT_PTR MsgBox(HWND hParent, UINT uType, LPTSTR pszTitle, LPTSTR pszInfo, LPTSTR pszFormat, ...);