diff options
author | René Schümann <white06tiger@gmail.com> | 2014-04-03 01:46:29 +0000 |
---|---|---|
committer | René Schümann <white06tiger@gmail.com> | 2014-04-03 01:46:29 +0000 |
commit | a58626275cfecfeae65ffb94e006483b1e344fde (patch) | |
tree | 39ef8a9a30974cdebd483201dd3e12ef255ccca1 /plugins/SendScreenshotPlus | |
parent | 3ff89e16119e063eb5719679e7b34d306116b265 (diff) |
SendSS: updated files imported from UserInfoEx (mir_string,mir_icolib,dlg_msgbox)
* renamed IDI_ constants to reflect UserInfoEx style
* use Skin_GetIcon() directly instead of IcoLib_GetIcon()
git-svn-id: http://svn.miranda-ng.org/main/trunk@8832 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SendScreenshotPlus')
-rw-r--r-- | plugins/SendScreenshotPlus/src/Main.cpp | 10 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/UAboutForm.cpp | 10 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/UMainForm.cpp | 37 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/ctrl_button.cpp | 8 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/dlg_msgbox.cpp | 1472 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/dlg_msgbox.h | 48 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/global.h | 3 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/mir_icolib.cpp | 328 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/mir_icolib.h | 62 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/mir_string.cpp | 13 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/mir_string.h | 27 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/resource.h | 212 |
12 files changed, 1059 insertions, 1171 deletions
diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp index 3c3028c77f..1324766388 100644 --- a/plugins/SendScreenshotPlus/src/Main.cpp +++ b/plugins/SendScreenshotPlus/src/Main.cpp @@ -9,7 +9,7 @@ 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++) +(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 @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. FI_INTERFACE *FIP = 0; HINSTANCE hInst; //!< Global reference to the application MGLOBAL myGlobals; -int hLangpack; +int hLangpack; //Information gathered by Miranda, displayed in the plugin pane of the Option Dialog @@ -307,21 +307,21 @@ void AddMenuItems(void) // Add item to contact menu mi.position = 1000000; mi.ptszName = LPGENT("Send Screenshot"); - mi.hIcon = IcoLib_GetIcon(ICO_PLUG_SSWINDOW2); + mi.hIcon = Skin_GetIcon(ICO_COMMON_SSWINDOW2); mi.pszService = MS_SENDSS_OPENDIALOG; Menu_AddContactMenuItem(&mi); // Add item to contact menu mi.position = 1000001; mi.ptszName = LPGENT("Send desktop screenshot"); -// mi.hIcon = IcoLib_GetIcon(ICO_PLUG_SSWINDOW2); +// mi.hIcon = Skin_GetIcon(ICO_COMMON_SSWINDOW2); mi.pszService = MS_SENDSS_SENDDESKTOP; Menu_AddContactMenuItem(&mi); // Add item to main menu mi.position = 1000001; mi.ptszName = LPGENT("Take a screenshot"); -// mi.hIcon = IcoLib_GetIcon(ICO_PLUG_SSWINDOW2); +// mi.hIcon = Skin_GetIcon(ICO_COMMON_SSWINDOW2); mi.pszService = MS_SENDSS_OPENDIALOG; Menu_AddMainMenuItem(&mi); } diff --git a/plugins/SendScreenshotPlus/src/UAboutForm.cpp b/plugins/SendScreenshotPlus/src/UAboutForm.cpp index ed86552c97..399992f384 100644 --- a/plugins/SendScreenshotPlus/src/UAboutForm.cpp +++ b/plugins/SendScreenshotPlus/src/UAboutForm.cpp @@ -103,7 +103,7 @@ LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) { mir_freeAndNil(pszPlug); mir_freeAndNil(pszVer); SetDlgItemText( m_hWnd, IDC_HEADERBAR, newTitle ); - SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, 0, (WPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); + SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(ICO_COMMON_SSWINDOW1,1)); //License { mir_tcsadd(pszTitle ,_T(__COPYRIGHT)); @@ -133,8 +133,8 @@ LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) { mir_freeAndNil(pszTitle); } - SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); - SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); + SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(ICO_COMMON_SSWINDOW1,1)); + SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon(ICO_COMMON_SSWINDOW2)); //init controls btnPageClick(); @@ -196,7 +196,7 @@ void TfrmAbout::btnPageClick() { ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_HIDE); ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_SHOW); SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Credits >"), MBBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWR); + HICON hIcon = Skin_GetIcon(ICO_COMMON_ARROWR); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetWindowText(hCtrl, hIcon ? TranslateT("Credits") : TranslateT("Credits >")); } @@ -204,7 +204,7 @@ void TfrmAbout::btnPageClick() { ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_SHOW); ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_HIDE); SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("< Copyright"), MBBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWL); + HICON hIcon = Skin_GetIcon(ICO_COMMON_ARROWL); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetWindowText(hCtrl, hIcon ? TranslateT("Copyright") : TranslateT("< Copyright")); } diff --git a/plugins/SendScreenshotPlus/src/UMainForm.cpp b/plugins/SendScreenshotPlus/src/UMainForm.cpp index 704677840c..60eb365011 100644 --- a/plugins/SendScreenshotPlus/src/UMainForm.cpp +++ b/plugins/SendScreenshotPlus/src/UMainForm.cpp @@ -9,7 +9,7 @@ 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++) +(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 @@ -45,7 +45,7 @@ INT_PTR CALLBACK TfrmMain::DlgProc_CaptureWindow(HWND hDlg, UINT uMsg, WPARAM wP // main message handling is done inside TfrmMain::DlgTfrmMain switch (uMsg) { case WM_INITDIALOG: - Static_SetIcon(GetDlgItem(hDlg, ID_imgTarget), IcoLib_GetIcon(ICO_PLUG_SSTARGET)); + Static_SetIcon(GetDlgItem(hDlg, ID_imgTarget), Skin_GetIcon(ICO_COMMON_SSTARGET)); SetDlgItemText(hDlg, ID_edtCaption, TranslateT("Drag&Drop the target on the desired window.")); TranslateDialogDefault(hDlg); break; @@ -90,7 +90,7 @@ INT_PTR CALLBACK TfrmMain::DlgProc_CaptureDesktop(HWND hDlg, UINT uMsg, WPARAM w // main message handling is done inside TfrmMain::DlgTfrmMain switch (uMsg) { case WM_INITDIALOG: - Static_SetIcon(GetDlgItem(hDlg, ID_imgTarget), IcoLib_GetIcon(ICO_PLUG_SSMONITOR)); + Static_SetIcon(GetDlgItem(hDlg, ID_imgTarget), Skin_GetIcon(ICO_COMMON_SSMONITOR)); break; case WM_CTLCOLOREDIT: case WM_CTLCOLORSTATIC: @@ -186,8 +186,8 @@ INT_PTR CALLBACK TfrmMain::DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARA void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) { HWND hCtrl; //Taskbar and Window icon - SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); - SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); + SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(ICO_COMMON_SSWINDOW1,1)); + SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon(ICO_COMMON_SSWINDOW2)); LPTSTR pt = mir_a2t(__PLUGIN_NAME); SetWindowText(m_hWnd, pt); mir_freeAndNil(pt); @@ -203,7 +203,7 @@ void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) { } mir_freeAndNil(pt); - SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, 0, (WPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); + SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(ICO_COMMON_SSWINDOW1,1)); //Timed controls CheckDlgButton(m_hWnd,ID_chkTimed, m_opt_chkTimed ? BST_CHECKED : BST_UNCHECKED); @@ -215,8 +215,8 @@ void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) { if(m_himlTab == 0){ //m_himlTab = ImageList_Create(16, 16, PluginConfig.m_bIsXP ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 2, 0); m_himlTab = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0); - ImageList_AddIcon(m_himlTab, IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); - ImageList_AddIcon(m_himlTab, IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); + ImageList_AddIcon(m_himlTab, Skin_GetIcon(ICO_COMMON_SSWINDOW2)); + ImageList_AddIcon(m_himlTab, Skin_GetIcon(ICO_COMMON_SSWINDOW2)); } //create the tab control. @@ -323,21 +323,21 @@ void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) { if (hCtrl = GetDlgItem(m_hWnd, ID_btnAbout)) { SendDlgItemMessage(m_hWnd, ID_btnAbout, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Information"), MBBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_PLUG_SSHELP); + HICON hIcon = Skin_GetIcon(ICO_COMMON_SSHELP); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetWindowText(hCtrl, hIcon ? _T("") : _T("?")); } if (hCtrl = GetDlgItem(m_hWnd, ID_btnExplore)) { SendDlgItemMessage(m_hWnd, ID_btnExplore, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open Folder"), MBBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_PLUG_SSFOLDERO); + HICON hIcon = Skin_GetIcon(ICO_COMMON_SSFOLDERO); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetWindowText(hCtrl, hIcon ? _T("") : _T("...")); } if (hCtrl = GetDlgItem(m_hWnd, ID_btnDesc)) { SendDlgItemMessage(m_hWnd, ID_btnDesc, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Fill description textbox."), MBBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF); + HICON hIcon = Skin_GetIcon(m_opt_btnDesc ? ICO_COMMON_SSDESKON : ICO_COMMON_SSDESKOFF); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetWindowText(hCtrl, hIcon ? _T("") : _T("D")); SendMessage(hCtrl, BM_SETCHECK, m_opt_btnDesc ? BST_CHECKED : BST_UNCHECKED, NULL); @@ -345,7 +345,7 @@ void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) { if (hCtrl = GetDlgItem(m_hWnd, ID_btnDeleteAfterSend)) { SendDlgItemMessage(m_hWnd, ID_btnDeleteAfterSend, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete after send"), MBBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF); + HICON hIcon = Skin_GetIcon(m_opt_btnDeleteAfterSend ? ICO_COMMON_SSDELON : ICO_COMMON_SSDELOFF); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetWindowText(hCtrl, hIcon ? _T("") : _T("X")); SendMessage(hCtrl, BM_SETCHECK, m_opt_btnDeleteAfterSend ? BST_CHECKED : BST_UNCHECKED, NULL); @@ -353,11 +353,12 @@ void TfrmMain::wmInitdialog(WPARAM wParam, LPARAM lParam) { if (hCtrl = GetDlgItem(m_hWnd, ID_btnCapture)) { SendDlgItemMessage(m_hWnd, ID_btnCapture, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Capture"), MBBF_TCHAR); - HICON hIcon = IcoLib_GetIcon(ICO_PLUG_OK); + HICON hIcon = Skin_GetIcon(ICO_BTN_OK); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetWindowText(hCtrl, TranslateT("&Capture")); SendMessage(hCtrl, BUTTONSETDEFAULT, 1, NULL); } + cboxSendByChange(); //enable disable controls // CheckDlgButton(m_hWnd,ID_chkEditor, m_opt_chkEditor ? BST_CHECKED : BST_UNCHECKED); TranslateDialogDefault(m_hWnd); @@ -401,13 +402,13 @@ void TfrmMain::wmCommand(WPARAM wParam, LPARAM lParam) { break; case ID_btnDesc:{ m_opt_btnDesc=!m_opt_btnDesc; - HICON hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF); + HICON hIcon = Skin_GetIcon(m_opt_btnDesc ? ICO_COMMON_SSDESKON : ICO_COMMON_SSDESKOFF); SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); break;} case ID_btnDeleteAfterSend: { m_opt_btnDeleteAfterSend = (m_opt_btnDeleteAfterSend == 0); - HICON hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF); + HICON hIcon = Skin_GetIcon(m_opt_btnDeleteAfterSend ? ICO_COMMON_SSDELON : ICO_COMMON_SSDELOFF); SendMessage((HWND)lParam, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); if(m_cSend) m_cSend->m_bDeleteAfterSend = m_opt_btnDeleteAfterSend; } @@ -498,7 +499,7 @@ void TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam){ m_hTargetHighlighter=CreateWindowEx(WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOOLWINDOW,(LPTSTR)g_clsTargetHighlighter,NULL,WS_POPUP,0,0,0,0,NULL,NULL,hInst,NULL); if(!m_hTargetHighlighter) return; SetLayeredWindowAttributes(m_hTargetHighlighter,0,123,LWA_ALPHA); - SetSystemCursor(CopyCursor(IcoLib_GetIcon(ICO_PLUG_SSTARGET)),OCR_NORMAL); + SetSystemCursor(CopyCursor(Skin_GetIcon(ICO_COMMON_SSTARGET)),OCR_NORMAL); Hide(); } if(!(GetAsyncKeyState(primarymouse)&0x8000)){ @@ -846,12 +847,12 @@ void TfrmMain::cboxSendByChange() { m_cSend->m_bDeleteAfterSend = m_opt_btnDeleteAfterSend; } bState = (itemFlag & SS_DLG_DELETEAFTERSSEND); - hIcon = IcoLib_GetIcon(m_opt_btnDeleteAfterSend ? ICO_PLUG_SSDELON : ICO_PLUG_SSDELOFF); + hIcon = Skin_GetIcon(m_opt_btnDeleteAfterSend ? ICO_COMMON_SSDELON : ICO_COMMON_SSDELOFF); SendMessage(GetDlgItem(m_hWnd, ID_btnDeleteAfterSend), BM_SETIMAGE, IMAGE_ICON, (LPARAM)(bState ? hIcon : 0)); Button_Enable(GetDlgItem(m_hWnd, ID_btnDeleteAfterSend), bState); bState = (itemFlag & SS_DLG_DESCRIPTION); - hIcon = IcoLib_GetIcon(m_opt_btnDesc ? ICO_PLUG_SSDESKON : ICO_PLUG_SSDESKOFF); + hIcon = Skin_GetIcon(m_opt_btnDesc ? ICO_COMMON_SSDESKON : ICO_COMMON_SSDESKOFF); SendMessage(GetDlgItem(m_hWnd, ID_btnDesc), BM_SETIMAGE, IMAGE_ICON, (LPARAM)(bState ? hIcon : 0)); Button_Enable(GetDlgItem(m_hWnd, ID_btnDesc), bState); } diff --git a/plugins/SendScreenshotPlus/src/ctrl_button.cpp b/plugins/SendScreenshotPlus/src/ctrl_button.cpp index 5fec26836f..2bbc461f2b 100644 --- a/plugins/SendScreenshotPlus/src/ctrl_button.cpp +++ b/plugins/SendScreenshotPlus/src/ctrl_button.cpp @@ -367,7 +367,7 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L bct->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); bct->dwStyle = cs->style; if (cs->style & MBS_DOWNARROW) - bct->arrow = IcoLib_GetIcon(ICO_PLUG_DOWNARROW); + bct->arrow = Skin_GetIcon(ICO_BTN_DOWNARROW); LoadTheme(bct); SetWindowLongPtr(hwndBtn, 0, (LONG_PTR)bct); if (cs->lpszName) SetWindowText(hwndBtn, cs->lpszName); @@ -400,8 +400,8 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L break; case WM_SETTEXT: bct->cHot = 0; - if ((LPTSTR)lParam) { - LPTSTR tmp = (LPTSTR)lParam; + if(lParam) { + TCHAR* tmp = (TCHAR*)lParam; while (*tmp) { if (*tmp=='&' && *(tmp+1)) { @@ -535,7 +535,7 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L } ti.uFlags = TTF_IDISHWND|TTF_SUBCLASS; ti.uId = (UINT_PTR)bct->hwnd; - ti.lpszText=(LPSTR)wParam; + ti.lpszText=(char*)wParam; SendMessage(hwndToolTips, TTM_ADDTOOLA, 0, (LPARAM)&ti); } LeaveCriticalSection(&csTips); diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp index 65d7f0d8ba..68fd332cce 100644 --- a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp +++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp @@ -1,779 +1,693 @@ -/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
-Copyright (c) 2000-09 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.
-*/
-
-#include "global.h"
-
-typedef struct _MSGPOPUPDATA
-{
- POPUPACTION pa[3];
- HWND hDialog;
-}
-MSGPOPUPDATA, *LPMSGPOPUPDATA;
-
-/**
- * This helper function moves and resizes a dialog box's control element.
- *
- * @param hDlg - the dialog box's window handle
- * @param idCtrl - the identication number of the control to move
- * @param dx -´number of pixels to horizontal move the control
- * @param dy - number of pixels to vertical move the control
- * @param dw - number of pixels to horizontal resize the control
- * @param dh - number of pixels to vertical resize the control
- *
- * @return nothing
- **/
-static FORCEINLINE VOID MoveCtrl(HWND hDlg, INT idCtrl, INT dx, INT dy, INT dw, INT dh)
-{
- RECT ws;
- HWND hCtrl = GetDlgItem(hDlg, idCtrl);
- GetWindowRect(hCtrl, &ws);
- OffsetRect(&ws, dx, dy);
- MoveWindow(hCtrl, ws.left, ws.top, ws.right - ws.left + dw, ws.bottom - ws.top + dh, FALSE);
-}
-
-/**
- * This function loads the icon to display for the current message.
- *
- * @param pMsgBox - pointer to a MSGBOX structure, with information about the message to display.
- *
- * @retval HICON - The function returns an icon to display with the message.
- * @retval NULL - There is no icon for the message.
- **/
-HICON MsgLoadIcon(LPMSGBOX pMsgBox)
-{
- HICON hIcon;
-
- // load the desired status icon
- switch (pMsgBox->uType & MB_ICONMASK)
- {
-
- // custom icon defined by caller function
- case MB_ICON_OTHER:
- {
- hIcon = pMsgBox->hiMsg;
- }
- break;
-
- // default windows icons
- case MB_ICON_ERROR:
- case MB_ICON_QUESTION:
- case MB_ICON_WARNING:
- case MB_ICON_INFO:
- {
- LPCTSTR ico[] = { 0, IDI_ERROR, IDI_QUESTION, IDI_WARNING, IDI_INFORMATION };
- hIcon = LoadIcon(NULL, ico[MB_ICON_INDEX(pMsgBox->uType)]);
- }
- break;
-
- // no icon
- default:
- {
- hIcon = NULL;
- }
- }
- return hIcon;
-}
-
-/**
- * This function fills a given POPUPACTION structure with the data of a given message id,
- * which is normally used by the message box. This is required to let the user interact
- * with a popup in the same way as with a normal message dialog box.
- *
- * @param pa - reference to a POPUPACTION structure to fill
- * @param id - the message id
- * @param result - This parameter is passed to the POPUPACTION structure as is.
- *
- * @return nothing
- **/
-void MakePopupAction(POPUPACTION &pa, INT id)
-{
- pa.cbSize = sizeof(POPUPACTION);
- pa.flags = PAF_ENABLED;
- pa.wParam = MAKEWORD(id, BN_CLICKED);
- pa.lParam = 0;
-
- switch (id) {
- case IDOK:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK);
- lstrcpyA(pa.lpzTitle, MODNAME"/Ok");
- break;
-
- case IDCLOSE:
- case IDCANCEL:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL);
- lstrcpyA(pa.lpzTitle, MODNAME"/Cancel");
- break;
-
- case IDABORT:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL);
- lstrcpyA(pa.lpzTitle, MODNAME"/Abort");
- break;
-
- case IDRETRY:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_UPDATE);
- lstrcpyA(pa.lpzTitle, MODNAME"/Retry");
- break;
-
- case IDIGNORE:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK);
- lstrcpyA(pa.lpzTitle, MODNAME"/Ignore");
- break;
-
- case IDYES:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK);
- lstrcpyA(pa.lpzTitle, MODNAME"/Yes");
- break;
-
- case IDNO:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL);
- lstrcpyA(pa.lpzTitle, MODNAME"/No");
- break;
-
- case IDHELP:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL);
- lstrcpyA(pa.lpzTitle, MODNAME"/Help");
- break;
-
- case IDALL:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK);
- lstrcpyA(pa.lpzTitle, MODNAME"/All");
- break;
-
- case IDNONE:
- pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL);
- lstrcpyA(pa.lpzTitle, MODNAME"/None");
- }
-}
-
-/**
- * This is the message procedure for my nice looking message box
- *
- * @param hDlg - window handle
- * @param uMsg - message to handle
- * @param wParam - message specific parameter
- * @param lParam - message specific parameter
- *
- * @return TRUE, FALSE, IDOK, IDYES, IDALL, IDNO or IDCANCEL
- **/
-INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- static INT retOk = IDOK;
- static INT retAll = IDALL;
- static INT retNon = IDNONE;
- static INT retCancel = IDCANCEL;
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
- {
- LPMSGBOX pMsgBox = (LPMSGBOX)lParam;
-
- if (PtrIsValid(pMsgBox))
- {
- INT icoWidth = 0;
- INT InfoBarHeight = 0;
- HFONT hNormalFont;
-
- hNormalFont = (HFONT)SendDlgItemMessage(hDlg, TXT_NAME, WM_GETFONT, 0, 0);
- if (pMsgBox->uType & MB_INFOBAR)
- {
- LOGFONT lf;
-
- // set bold font for name in description area
- GetObject(hNormalFont, sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- hNormalFont = CreateFontIndirect(&lf);
-
- // set infobar's textfont
- SendDlgItemMessage(hDlg, TXT_NAME, WM_SETFONT, (WPARAM)hNormalFont, 0);
-
- // set infobar's logo icon
- SendDlgItemMessage(hDlg, ICO_DLGLOGO, STM_SETIMAGE, IMAGE_ICON,
- (LPARAM)((pMsgBox->hiLogo) ? pMsgBox->hiLogo : IcoLib_GetIcon(ICO_DLG_DETAILS)));
-
- // anable headerbar
- ShowWindow(GetDlgItem(hDlg, TXT_NAME), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, ICO_DLGLOGO), SW_SHOW);
- }
- else
- {
- RECT rc;
- GetClientRect(GetDlgItem(hDlg, TXT_NAME), &rc);
- InfoBarHeight = rc.bottom;
-
- if (pMsgBox->hiLogo)
- {
- SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)pMsgBox->hiLogo);
- }
- }
-
- // draw the desired status icon
- HICON hIcon = MsgLoadIcon(pMsgBox);
- if (hIcon)
- {
- SendDlgItemMessage(hDlg, ICO_MSGDLG, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- }
- else
- {
- RECT ws;
- GetWindowRect(GetDlgItem(hDlg, ICO_MSGDLG), &ws);
- icoWidth = ws.right - ws.left;
- ShowWindow(GetDlgItem(hDlg, ICO_MSGDLG), SW_HIDE);
- }
-
- // resize the messagebox and reorganize the buttons
- if (HDC hDC = GetDC(hDlg))
- {
- POINT mpt = {0,0};
- RECT ws = {0,0,0,0};
- INT txtWidth,
- txtHeight,
- needX, needY;
- RECT rcDlg;
- SIZE ts;
- LPTSTR h, rs;
-
- SelectObject(hDC, hNormalFont);
-
- for (rs = h = pMsgBox->ptszMsg, txtHeight = 0, txtWidth = 0; h; h++)
- {
- if (*h == '\n' || *h == '\0')
- {
- GetTextExtentPoint32(hDC, rs, h - rs, &ts);
- if (ts.cx > txtWidth)
- {
- txtWidth = ts.cx;
- }
- txtHeight += ts.cy;
- if (*h == '\0')
- {
- break;
- }
- rs = h + 1;
- }
- }
- ReleaseDC(hDlg, hDC);
-
- // calc new dialog size
- GetWindowRect(hDlg, &rcDlg);
- GetWindowRect(GetDlgItem(hDlg, TXT_MESSAGE), &ws);
- needX = txtWidth - (ws.right - ws.left) - icoWidth;
- needY = max(0, txtHeight - (ws.bottom - ws.top) + 5);
- rcDlg.left -= needX/2; rcDlg.right += needX/2;
- rcDlg.top -= (needY-InfoBarHeight)/2; rcDlg.bottom += (needY-InfoBarHeight)/2;
-
- // resize dialog window
- MoveWindow(hDlg,
- rcDlg.left, rcDlg.top,
- rcDlg.right - rcDlg.left,
- rcDlg.bottom - rcDlg.top,
- FALSE);
- ClientToScreen(hDlg, &mpt);
-
- MoveCtrl(hDlg, STATIC_WHITERECT, -mpt.x, -mpt.y, needX, needY - InfoBarHeight);
- MoveCtrl(hDlg, TXT_NAME, -mpt.x, -mpt.y, needX, 0);
- MoveCtrl(hDlg, ICO_DLGLOGO, -mpt.x + needX, -mpt.y, 0, 0);
- MoveCtrl(hDlg, ICO_MSGDLG, -mpt.x, -mpt.y - InfoBarHeight, 0, 0);
- MoveCtrl(hDlg, TXT_MESSAGE, -mpt.x - icoWidth, -mpt.y - InfoBarHeight, needX, needY);
- MoveCtrl(hDlg, STATIC_LINE2, -mpt.x, -mpt.y + needY - InfoBarHeight, needX, 0);
-
- //
- // Do pushbutton positioning
- //
- {
- RECT rcOk, rcAll, rcNone, rcCancel;
- LONG okWidth, caWidth, allWidth, noneWidth, dlgMid;
-
- // get button rectangles
- GetWindowRect(GetDlgItem(hDlg, IDOK), &rcOk);
- OffsetRect(&rcOk, -mpt.x, -mpt.y + needY - InfoBarHeight);
-
- GetWindowRect(GetDlgItem(hDlg, IDALL), &rcAll);
- OffsetRect(&rcAll, -mpt.x, -mpt.y + needY - InfoBarHeight);
-
- GetWindowRect(GetDlgItem(hDlg, IDNONE), &rcNone);
- OffsetRect(&rcNone, -mpt.x, -mpt.y + needY - InfoBarHeight);
-
- GetWindowRect(GetDlgItem(hDlg, IDCANCEL), &rcCancel);
- OffsetRect(&rcCancel, -mpt.x, -mpt.y + needY - InfoBarHeight);
-
- okWidth = rcOk.right - rcOk.left;
- allWidth = rcAll.right - rcAll.left;
- noneWidth = rcNone.right - rcNone.left;
- caWidth = rcCancel.right - rcCancel.left;
- dlgMid = (rcDlg.right - rcDlg.left) / 2;
-
- // load button configuration
- switch (MB_TYPE(pMsgBox->uType))
- {
-
- case MB_OK:
- {
- rcOk.left = dlgMid - (okWidth / 2);
- rcOk.right = rcOk.left + okWidth;
- ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW);
- }
- break;
-
- case MB_OKCANCEL:
- {
- retOk = IDRETRY;
- SetDlgItemText(hDlg, IDOK, LPGENT("OK"));
- retCancel = IDCANCEL;
- SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel"));
- rcOk.left = dlgMid - okWidth - 10;
- rcOk.right = rcOk.left + okWidth;
- rcCancel.left = dlgMid + 10;
- rcCancel.right = rcCancel.left + caWidth;
- ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW);
- }
- break;
-
- case MB_RETRYCANCEL:
- {
- retOk = IDRETRY;
- SetDlgItemText(hDlg, IDOK, LPGENT("Retry"));
- retCancel = IDCANCEL;
- SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel"));
- rcOk.left = dlgMid - okWidth - 10;
- rcOk.right = rcOk.left + okWidth;
- rcCancel.left = dlgMid + 10;
- rcCancel.right = rcCancel.left + caWidth;
- ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW);
- }
- break;
-
- case MB_YESNO:
- {
- retOk = IDYES;
- SetDlgItemText(hDlg, IDOK, LPGENT("Yes"));
- retCancel = IDNO;
- SetDlgItemText(hDlg, IDCANCEL, LPGENT("No"));
- rcOk.left = dlgMid - okWidth - 10;
- rcOk.right = rcOk.left + okWidth;
- rcCancel.left = dlgMid + 10;
- rcCancel.right = rcCancel.left + caWidth;
- ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW);
- }
- break;
-
- case MB_ABORTRETRYIGNORE:
- {
- retOk = IDABORT;
- SetDlgItemText(hDlg, IDOK, LPGENT("Abort"));
- retAll = IDABORT;
- SetDlgItemText(hDlg, IDALL, LPGENT("Retry"));
- retCancel = IDCANCEL;
- SetDlgItemText(hDlg, IDCANCEL, LPGENT("Ignore"));
- rcAll.left = dlgMid - (allWidth / 2);
- rcAll.right = rcAll.left + allWidth;
- rcOk.left = rcAll.left - okWidth - 5;
- rcOk.right = rcOk.left + okWidth;
- rcCancel.left = rcAll.right + 5;
- rcCancel.right = rcCancel.left + caWidth;
- ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW);
- }
- break;
-
- case MB_YESNOCANCEL:
- {
- retOk = IDYES;
- SetDlgItemText(hDlg, IDOK, LPGENT("Yes"));
- retAll = IDNO;
- SetDlgItemText(hDlg, IDALL, LPGENT("No"));
- retCancel = IDCANCEL;
- SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel"));
- rcAll.left = dlgMid - (allWidth / 2);
- rcAll.right = rcAll.left + allWidth;
- rcOk.left = rcAll.left - okWidth - 5;
- rcOk.right = rcOk.left + okWidth;
- rcCancel.left = rcAll.right + 5;
- rcCancel.right = rcCancel.left + caWidth;
- ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW);
- }
- break;
-
- case MB_YESALLNO:
- {
- retOk = IDYES;
- SetDlgItemText(hDlg, IDOK, LPGENT("Yes"));
- retAll = IDALL;
- SetDlgItemText(hDlg, IDALL, LPGENT("All"));
- //retNon = IDNONE;
- SetDlgItemText(hDlg, IDNONE, LPGENT("None"));
- retCancel = IDNO;
- SetDlgItemText(hDlg, IDCANCEL, LPGENT("No"));
- rcCancel.right = rcDlg.right - rcDlg.left - 10;
- rcCancel.left = rcCancel.right - caWidth;
- rcNone.right = rcCancel.left - 5;
- rcNone.left = rcNone.right - noneWidth;
- rcAll.right = rcNone.left - 5;
- rcAll.left = rcAll.right - allWidth;
- rcOk.right = rcAll.left - 5;
- rcOk.left = rcOk.right - okWidth;
- // show buttons
- ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDNONE), SW_SHOW);
- ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW);
- }
- break;
-
- default:
- {
- rcOk.left = dlgMid - (okWidth / 2);
- rcOk.right = rcOk.left + okWidth;
- }
- }
- // move ok button
- MoveWindow(GetDlgItem(hDlg, IDOK),
- rcOk.left, rcOk.top,
- rcOk.right - rcOk.left, rcOk.bottom - rcOk.top,
- FALSE);
- // move all button
- MoveWindow(GetDlgItem(hDlg, IDALL),
- rcAll.left, rcAll.top,
- rcAll.right - rcAll.left, rcAll.bottom - rcAll.top,
- FALSE);
- // move none button
- MoveWindow(GetDlgItem(hDlg, IDNONE),
- rcNone.left, rcNone.top,
- rcNone.right - rcNone.left, rcNone.bottom - rcNone.top,
- FALSE);
- // move cancel button
- MoveWindow(GetDlgItem(hDlg, IDCANCEL),
- rcCancel.left, rcCancel.top,
- rcCancel.right - rcCancel.left, rcCancel.bottom - rcCancel.top,
- FALSE);
- } // end* Do pushbutton positioning
- } // end* resize the messagebox and reorganize the buttons
-
- TranslateDialogDefault(hDlg);
-
- // set text's
- SetWindowText(hDlg, pMsgBox->ptszTitle);
- SetDlgItemText(hDlg, TXT_NAME, pMsgBox->ptszInfoText);
- SetDlgItemText(hDlg, TXT_MESSAGE, pMsgBox->ptszMsg);
-
- return TRUE;
- } // end* PtrIsValid(pMsgBox)
- } // end* WM_INITDIALOG:
- break;
-
- case WM_CTLCOLORSTATIC:
- {
- switch (GetWindowLongPtr((HWND)lParam, GWL_ID))
- {
- case STATIC_WHITERECT:
- case ICO_DLGLOGO:
- case ICO_MSGDLG:
- case TXT_MESSAGE:
- case TXT_NAME:
- {
- SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
- return GetSysColor(COLOR_WINDOW);
- }
- }
- }
- break;
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDOK:
- EndDialog(hDlg, retOk);
- break;
- case IDCANCEL:
- EndDialog(hDlg, retCancel);
- break;
- case IDALL:
- EndDialog(hDlg, retAll);
- break;
- case IDNONE:
- EndDialog(hDlg, retNon);
- }
- }
- break;
-
- case WM_DESTROY:
- {
- DeleteObject((HFONT)SendDlgItemMessage(hDlg, TXT_NAME, WM_GETFONT, 0, 0));
- }
- break;
- }
- return FALSE;
-}
-
-
-/**
- * Dummi modal MsgBox for popup,
- * this set call function in wait stait and do not freece miranda main thread
- * the window is outside the desktop
- */
-INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg) {
- case WM_INITDIALOG:
- {
- MoveWindow(hDlg,-10,-10,0,0,FALSE);
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA));
- if (pmpd) {
- POPUPDATAT_V2 pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.lchContact = NULL; //(HANDLE)wParam;
-
- // icon
- LPMSGBOX pMsgBox = (LPMSGBOX)lParam;
- pd.lchIcon = MsgLoadIcon(pMsgBox);
- mir_tcsncpy(pd.lptzContactName, pMsgBox->ptszTitle, SIZEOF(pd.lptzContactName));
- mir_tcsncpy(pd.lptzText, pMsgBox->ptszMsg, SIZEOF(pd.lptzText));
-
- // CALLBAC Proc
- pd.PluginWindowProc = PopupProc;
- pd.PluginData = pmpd;
-
- pd.iSeconds = -1;
-
- pd.hNotification = NULL;
- pd.lpActions = pmpd->pa;
-
- // set color of popup
- switch (pMsgBox->uType & MB_ICONMASK) {
- case MB_ICON_ERROR:
- pd.colorBack = RGB(200, 10, 0);
- pd.colorText = RGB(255, 255, 255);
- break;
-
- case MB_ICON_WARNING:
- pd.colorBack = RGB(200, 100, 0);
- pd.colorText = RGB(255, 255, 255);
- break;
-
- default:
- if (pMsgBox->uType & MB_CUSTOMCOLOR) {
- pd.colorBack = pMsgBox->colorBack;
- pd.colorText = pMsgBox->colorText;
- }
- }
-
- // handle for MakePopupAction
- pmpd->hDialog = hDlg;
-
- // active buttons
- switch (MB_TYPE(pMsgBox->uType)) {
- case MB_OK:
- MakePopupAction(pmpd->pa[pd.actionCount++], IDOK);
- break;
-
- case MB_OKCANCEL:
- MakePopupAction(pmpd->pa[pd.actionCount++], IDOK);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL);
- break;
-
- case MB_RETRYCANCEL:
- MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL);
- break;
-
- case MB_YESNO:
- MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
- break;
-
- case MB_ABORTRETRYIGNORE:
- MakePopupAction(pmpd->pa[pd.actionCount++], IDABORT);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDIGNORE);
- break;
-
- case MB_YESNOCANCEL:
- MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL);
- break;
-
- case MB_YESALLNO:
- MakePopupAction(pmpd->pa[pd.actionCount++], IDYES);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDALL);
- MakePopupAction(pmpd->pa[pd.actionCount++], IDNO);
- break;
- }
-
- // create popup
- CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pd, APF_NEWDATA);
- if (MB_TYPE(pMsgBox->uType) == MB_OK)
- EndDialog(hDlg, IDOK);
- }
- break;
- }
- }
- return FALSE;
-}
-
-/**
-* This is the message procedure for popup
-*
-* @param hDlg - window handle
-* @param uMsg - message to handle
-* @param wParam - message specific parameter
-* @param lParam - message specific parameter
-*
-* @return TRUE, FALSE, IDOK, IDYES, IDALL, IDNO or IDCANCEL
-**/
-LRESULT CALLBACK PopupProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- switch (uMsg) {
- case UM_POPUPACTION:
- if (HIWORD(wParam) == BN_CLICKED) {
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg);
- if (pmpd) {
- switch (LOWORD(wParam)) {
- case IDOK:
- case IDCANCEL:
- case IDABORT:
- case IDRETRY:
- case IDIGNORE:
- case IDYES:
- case IDNO:
- case IDALL:
- case IDNONE:
- if (IsWindow(pmpd->hDialog))
- EndDialog(pmpd->hDialog, LOWORD(wParam));
- break;
-
- default:
- if (IsWindow(pmpd->hDialog))
- EndDialog(pmpd->hDialog, IDCANCEL);
- }
- }
- PUDeletePopup(hDlg);
- }
- break;
-
- case UM_FREEPLUGINDATA:
- LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg);
- if (pmpd > 0)
- mir_freeAndNil(pmpd);
- return TRUE; //TRUE or FALSE is the same, it gets ignored.
- }
- return DefWindowProc(hDlg, uMsg, wParam, lParam);
-}
-
-/**
- * This is the service function for external plugins to use the nice messagebox
- *
- * @param wParam - MCONTACT hContact which can display an avatar for popups
- * @param lParam - MSGBOX structure holding parameters
- *
- * @return The function returns the ID of the clicked button (IDOK, IDCANCEL, ...)
- * or -1 on error.
- **/
-INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam)
-{
- INT rc = -1;
- LPMSGBOX pMsgBox = (LPMSGBOX)lParam;
-
- // check input
- if (PtrIsValid(pMsgBox) && pMsgBox->cbSize == sizeof(MSGBOX))
- {
- // Shall the MessageBox displayed as popup?
- if (!(pMsgBox->uType & (MB_INFOBAR|MB_NOPOPUP)) && // message box can be a popup?
- ServiceExists(MS_POPUP_ADDPOPUPT) && // popups exist?
- myGlobals.PopupActionsExist == 1 && // popup support ext stuct?
- (db_get_dw(NULL, "Popup","Actions", 0) & 1) && // popup++ actions on?
- db_get_b(NULL, MODNAME, SET_POPUPMSGBOX, DEFVAL_POPUPMSGBOX) // user likes popups?
- )
- {
- rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOXDUMMI), pMsgBox->hParent, MsgBoxPop, lParam);
- }
- else
- {
- rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOX), pMsgBox->hParent, MsgBoxProc, lParam);
- }
- }
- return rc;
-}
-
-/**
- * name: MsgBox
- * desc: calls a messagebox
- * param:
- **/
-INT_PTR MsgBox(HWND hParent, UINT uType, LPTSTR pszTitle, LPTSTR pszInfo, LPTSTR pszFormat, ...)
-{
- MSGBOX mb = {0};
- TCHAR tszMsg[MAX_SECONDLINE];
- va_list vl;
-
- va_start(vl, pszFormat);
- mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl);
- va_end(vl);
-
- mb.cbSize = sizeof(MSGBOX);
- mb.hParent = hParent;
- mb.hiLogo = LoadIcon(hInst, MAKEINTRESOURCE(IDI_PLUG_MAIN));
- mb.hiMsg = NULL;
- mb.ptszTitle = TranslateTS(pszTitle);
- mb.ptszInfoText = TranslateTS(pszInfo);
- mb.ptszMsg = tszMsg;
- mb.uType = uType;
- return MsgBoxService(NULL, (LPARAM)&mb);
-}
-
-/**
- * name: MsgErr
- * desc: calls a messagebox
- * param:
- **/
-INT_PTR MsgErr(HWND hParent, LPCTSTR pszFormat, ...)
-{
- if(!pszFormat) return -1;
- MSGBOX mb = {0};
- TCHAR tszTitle[MAX_SECONDLINE];
- TCHAR tszMsg[MAX_SECONDLINE];
- va_list vl;
-
- mir_sntprintf(tszTitle, SIZEOF(tszMsg),_T("%s - %s") ,_T(MODNAME), TranslateT("Error"));
-
- va_start(vl, pszFormat);
- mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl);
- va_end(vl);
-
- mb.cbSize = sizeof(MSGBOX);
- mb.hParent = hParent;
- mb.hiLogo = LoadIcon(hInst, MAKEINTRESOURCE(IDI_PLUG_MAIN));
- mb.hiMsg = NULL;
- mb.ptszTitle = tszTitle;
- mb.ptszMsg = tszMsg;
- mb.uType = MB_OK|MB_ICON_ERROR;
- return MsgBoxService(NULL, (LPARAM)&mb);
-}
+/* +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-09 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. +*/ + +#include "global.h" + +typedef struct _MSGPOPUPDATA +{ + POPUPACTION pa[3]; + HWND hDialog; +} +MSGPOPUPDATA, *LPMSGPOPUPDATA; + +/** + * This helper function moves and resizes a dialog box's control element. + * + * @param hDlg - the dialog box's window handle + * @param idCtrl - the identication number of the control to move + * @param dx -�number of pixels to horizontal move the control + * @param dy - number of pixels to vertical move the control + * @param dw - number of pixels to horizontal resize the control + * @param dh - number of pixels to vertical resize the control + * + * @return nothing + **/ +static FORCEINLINE void MoveCtrl(HWND hDlg, int idCtrl, int dx, int dy, int dw, int dh) +{ + RECT ws; + HWND hCtrl = GetDlgItem(hDlg, idCtrl); + GetWindowRect(hCtrl, &ws); + OffsetRect(&ws, dx, dy); + MoveWindow(hCtrl, ws.left, ws.top, ws.right - ws.left + dw, ws.bottom - ws.top + dh, FALSE); +} + +/** +* This function loads the icon to display for the current message. +* +* @param pMsgBox - pointer to a MSGBOX structure, with information about the message to display. +* +* @retval HICON - The function returns an icon to display with the message. +* @retval NULL - There is no icon for the message. +**/ + +static HICON MsgLoadIcon(LPMSGBOX pMsgBox) +{ + HICON hIcon; + + // load the desired status icon + switch (pMsgBox->uType & MB_ICONMASK) { + case MB_ICON_OTHER: // custom icon defined by caller function + hIcon = pMsgBox->hiMsg; + break; + + // default windows icons + case MB_ICON_ERROR: + case MB_ICON_QUESTION: + case MB_ICON_WARNING: + case MB_ICON_INFO: + { + LPCTSTR ico[] = { 0, IDI_ERROR, IDI_QUESTION, IDI_WARNING, IDI_INFORMATION }; + hIcon = LoadIcon(NULL, ico[MB_ICON_INDEX(pMsgBox->uType)]); + } + break; + + // no icon + default: + hIcon = NULL; + } + return hIcon; +} + +/** + * This function fills a given POPUPACTION structure with the data of a given message id, + * which is normally used by the message box. This is required to let the user interact + * with a popup in the same way as with a normal message dialog box. + * + * @param pa - reference to a POPUPACTION structure to fill + * @param id - the message id + * @param result - This parameter is passed to the POPUPACTION structure as is. + * + * @return nothing + **/ +static void MakePopupAction(POPUPACTION &pa, int id) +{ + pa.cbSize = sizeof(POPUPACTION); + pa.flags = PAF_ENABLED; + pa.wParam = MAKEWORD(id, BN_CLICKED); + pa.lParam = 0; + + switch (id) { + case IDOK: + pa.lchIcon = Skin_GetIcon(ICO_BTN_OK); + mir_strcpy(pa.lpzTitle, MODNAME"/Ok"); + break; + + case IDCLOSE: + case IDCANCEL: + pa.lchIcon = Skin_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/Cancel"); + break; + + case IDABORT: + pa.lchIcon = Skin_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/Abort"); + break; + + case IDRETRY: + pa.lchIcon = Skin_GetIcon(ICO_BTN_UPDATE); + mir_strcpy(pa.lpzTitle, MODNAME"/Retry"); + break; + + case IDIGNORE: + pa.lchIcon = Skin_GetIcon(ICO_BTN_OK); + mir_strcpy(pa.lpzTitle, MODNAME"/Ignore"); + break; + + case IDYES: + pa.lchIcon = Skin_GetIcon(ICO_BTN_OK); + mir_strcpy(pa.lpzTitle, MODNAME"/Yes"); + break; + + case IDNO: + pa.lchIcon = Skin_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/No"); + break; + + case IDHELP: + pa.lchIcon = Skin_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/Help"); + break; + + case IDALL: + pa.lchIcon = Skin_GetIcon(ICO_BTN_OK); + mir_strcpy(pa.lpzTitle, MODNAME"/All"); + break; + + case IDNONE: + pa.lchIcon = Skin_GetIcon(ICO_BTN_CANCEL); + mir_strcpy(pa.lpzTitle, MODNAME"/None"); + } +} + +/** + * This is the message procedure for my nice looking message box + * + * @param hDlg - window handle + * @param uMsg - message to handle + * @param wParam - message specific parameter + * @param lParam - message specific parameter + * + * @return TRUE, FALSE, IDOK, IDYES, IDALL, IDNO or IDCANCEL + **/ +static INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static int retOk = IDOK; + static int retAll = IDALL; + static int retNon = IDNONE; + static int retCancel = IDCANCEL; + + switch (uMsg) { + case WM_INITDIALOG: + { + LPMSGBOX pMsgBox = (LPMSGBOX)lParam; + if (PtrIsValid(pMsgBox)) { + int icoWidth = 0; + int InfoBarHeight = 0; + HFONT hNormalFont; + + hNormalFont = (HFONT)SendDlgItemMessage(hDlg, TXT_NAME, WM_GETFONT, 0, 0); + if (pMsgBox->uType & MB_INFOBAR) { + LOGFONT lf; + + // set bold font for name in description area + GetObject(hNormalFont, sizeof(lf), &lf); + lf.lfWeight = FW_BOLD; + hNormalFont = CreateFontIndirect(&lf); + + // set infobar's textfont + SendDlgItemMessage(hDlg, TXT_NAME, WM_SETFONT, (WPARAM)hNormalFont, 0); + + // set infobar's logo icon + SendDlgItemMessage(hDlg, ICO_DLGLOGO, STM_SETIMAGE, IMAGE_ICON, + (LPARAM)((pMsgBox->hiLogo) ? pMsgBox->hiLogo : Skin_GetIcon(ICO_DLG_DETAILS,1))); + + // anable headerbar + ShowWindow(GetDlgItem(hDlg, TXT_NAME), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, ICO_DLGLOGO), SW_SHOW); + } + else { + RECT rc; + GetClientRect(GetDlgItem(hDlg, TXT_NAME), &rc); + InfoBarHeight = rc.bottom; + + if (pMsgBox->hiLogo) + SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)pMsgBox->hiLogo); + } + + // draw the desired status icon + HICON hIcon = MsgLoadIcon(pMsgBox); + if (hIcon) + SendDlgItemMessage(hDlg, ICO_MSGDLG, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + else { + RECT ws; + GetWindowRect(GetDlgItem(hDlg, ICO_MSGDLG), &ws); + icoWidth = ws.right - ws.left; + ShowWindow(GetDlgItem(hDlg, ICO_MSGDLG), SW_HIDE); + } + + // resize the messagebox and reorganize the buttons + if (HDC hDC = GetDC(hDlg)) { + POINT mpt = {0,0}; + RECT ws = {0,0,0,0}; + int txtWidth, txtHeight, needX, needY; + RECT rcDlg; + SIZE ts; + LPTSTR h, rs; + + SelectObject(hDC, hNormalFont); + + for (rs = h = pMsgBox->ptszMsg, txtHeight = 0, txtWidth = 0; h; ++h) { + if (*h == '\n' || *h == '\0') { + GetTextExtentPoint32(hDC, rs, h - rs, &ts); + if (ts.cx > txtWidth) + txtWidth = ts.cx; + + txtHeight += ts.cy; + if (*h == '\0') + break; + + rs = h + 1; + } + } + ReleaseDC(hDlg, hDC); + + // calc new dialog size + GetWindowRect(hDlg, &rcDlg); + GetWindowRect(GetDlgItem(hDlg, TXT_MESSAGE), &ws); + needX = txtWidth - (ws.right - ws.left) - icoWidth; + needY = max(0, txtHeight - (ws.bottom - ws.top) + 5); + rcDlg.left -= needX/2; rcDlg.right += needX/2; + rcDlg.top -= (needY-InfoBarHeight)/2; rcDlg.bottom += (needY-InfoBarHeight)/2; + + // resize dialog window + MoveWindow(hDlg, rcDlg.left, rcDlg.top, rcDlg.right - rcDlg.left, rcDlg.bottom - rcDlg.top, FALSE); + ClientToScreen(hDlg, &mpt); + + MoveCtrl(hDlg, STATIC_WHITERECT, -mpt.x, -mpt.y, needX, needY - InfoBarHeight); + MoveCtrl(hDlg, TXT_NAME, -mpt.x, -mpt.y, needX, 0); + MoveCtrl(hDlg, ICO_DLGLOGO, -mpt.x + needX, -mpt.y, 0, 0); + MoveCtrl(hDlg, ICO_MSGDLG, -mpt.x, -mpt.y - InfoBarHeight, 0, 0); + MoveCtrl(hDlg, TXT_MESSAGE, -mpt.x - icoWidth, -mpt.y - InfoBarHeight, needX, needY); + MoveCtrl(hDlg, STATIC_LINE2, -mpt.x, -mpt.y + needY - InfoBarHeight, needX, 0); + + // + // Do pushbutton positioning + // + RECT rcOk, rcAll, rcNone, rcCancel; + + // get button rectangles + GetWindowRect(GetDlgItem(hDlg, IDOK), &rcOk); + OffsetRect(&rcOk, -mpt.x, -mpt.y + needY - InfoBarHeight); + + GetWindowRect(GetDlgItem(hDlg, IDALL), &rcAll); + OffsetRect(&rcAll, -mpt.x, -mpt.y + needY - InfoBarHeight); + + GetWindowRect(GetDlgItem(hDlg, IDNONE), &rcNone); + OffsetRect(&rcNone, -mpt.x, -mpt.y + needY - InfoBarHeight); + + GetWindowRect(GetDlgItem(hDlg, IDCANCEL), &rcCancel); + OffsetRect(&rcCancel, -mpt.x, -mpt.y + needY - InfoBarHeight); + + LONG okWidth = rcOk.right - rcOk.left; + LONG allWidth = rcAll.right - rcAll.left; + LONG noneWidth = rcNone.right - rcNone.left; + LONG caWidth = rcCancel.right - rcCancel.left; + LONG dlgMid = (rcDlg.right - rcDlg.left) / 2; + + // load button configuration + switch (MB_TYPE(pMsgBox->uType)) { + case MB_OK: + rcOk.left = dlgMid - (okWidth / 2); + rcOk.right = rcOk.left + okWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + break; + + case MB_OKCANCEL: + retOk = IDRETRY; + SetDlgItemText(hDlg, IDOK, LPGENT("OK")); + retCancel = IDCANCEL; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel")); + rcOk.left = dlgMid - okWidth - 10; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = dlgMid + 10; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + break; + + case MB_RETRYCANCEL: + retOk = IDRETRY; + SetDlgItemText(hDlg, IDOK, LPGENT("Retry")); + retCancel = IDCANCEL; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel")); + rcOk.left = dlgMid - okWidth - 10; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = dlgMid + 10; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + break; + + case MB_YESNO: + retOk = IDYES; + SetDlgItemText(hDlg, IDOK, LPGENT("Yes")); + retCancel = IDNO; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("No")); + rcOk.left = dlgMid - okWidth - 10; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = dlgMid + 10; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + break; + + case MB_ABORTRETRYIGNORE: + retOk = IDABORT; + SetDlgItemText(hDlg, IDOK, LPGENT("Abort")); + retAll = IDABORT; + SetDlgItemText(hDlg, IDALL, LPGENT("Retry")); + retCancel = IDCANCEL; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("Ignore")); + rcAll.left = dlgMid - (allWidth / 2); + rcAll.right = rcAll.left + allWidth; + rcOk.left = rcAll.left - okWidth - 5; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = rcAll.right + 5; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + break; + + case MB_YESNOCANCEL: + retOk = IDYES; + SetDlgItemText(hDlg, IDOK, LPGENT("Yes")); + retAll = IDNO; + SetDlgItemText(hDlg, IDALL, LPGENT("No")); + retCancel = IDCANCEL; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("Cancel")); + rcAll.left = dlgMid - (allWidth / 2); + rcAll.right = rcAll.left + allWidth; + rcOk.left = rcAll.left - okWidth - 5; + rcOk.right = rcOk.left + okWidth; + rcCancel.left = rcAll.right + 5; + rcCancel.right = rcCancel.left + caWidth; + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + break; + + case MB_YESALLNO: + retOk = IDYES; + SetDlgItemText(hDlg, IDOK, LPGENT("Yes")); + retAll = IDALL; + SetDlgItemText(hDlg, IDALL, LPGENT("All")); + //retNon = IDNONE; + SetDlgItemText(hDlg, IDNONE, LPGENT("None")); + retCancel = IDNO; + SetDlgItemText(hDlg, IDCANCEL, LPGENT("No")); + rcCancel.right = rcDlg.right - rcDlg.left - 10; + rcCancel.left = rcCancel.right - caWidth; + rcNone.right = rcCancel.left - 5; + rcNone.left = rcNone.right - noneWidth; + rcAll.right = rcNone.left - 5; + rcAll.left = rcAll.right - allWidth; + rcOk.right = rcAll.left - 5; + rcOk.left = rcOk.right - okWidth; + // show buttons + ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDALL), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDNONE), SW_SHOW); + ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_SHOW); + break; + + default: + rcOk.left = dlgMid - (okWidth / 2); + rcOk.right = rcOk.left + okWidth; + } + + MoveWindow(GetDlgItem(hDlg, IDOK), rcOk.left, rcOk.top, rcOk.right - rcOk.left, rcOk.bottom - rcOk.top, FALSE); + MoveWindow(GetDlgItem(hDlg, IDALL), rcAll.left, rcAll.top, rcAll.right - rcAll.left, rcAll.bottom - rcAll.top, FALSE); + MoveWindow(GetDlgItem(hDlg, IDNONE), rcNone.left, rcNone.top, rcNone.right - rcNone.left, rcNone.bottom - rcNone.top, FALSE); + MoveWindow(GetDlgItem(hDlg, IDCANCEL), rcCancel.left, rcCancel.top, rcCancel.right - rcCancel.left, rcCancel.bottom - rcCancel.top, FALSE); + } + + // set text's + SetWindowText(hDlg, pMsgBox->ptszTitle); + SetDlgItemText(hDlg, TXT_NAME, pMsgBox->ptszInfoText); + SetDlgItemText(hDlg, TXT_MESSAGE, pMsgBox->ptszMsg); + + TranslateDialogDefault(hDlg); + return TRUE; + } + } + break; + + case WM_CTLCOLORSTATIC: + switch (GetWindowLongPtr((HWND)lParam, GWLP_ID)) { + case STATIC_WHITERECT: + case ICO_DLGLOGO: + case ICO_MSGDLG: + case TXT_MESSAGE: + case TXT_NAME: + SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); + return GetSysColor(COLOR_WINDOW); + } + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + EndDialog(hDlg, retOk); + break; + case IDCANCEL: + EndDialog(hDlg, retCancel); + break; + case IDALL: + EndDialog(hDlg, retAll); + break; + case IDNONE: + EndDialog(hDlg, retNon); + } + break; + + case WM_DESTROY: + DeleteObject((HFONT)SendDlgItemMessage(hDlg, TXT_NAME, WM_GETFONT, 0, 0)); + break; + } + return FALSE; +} + +/** +* Dummi modal MsgBox for popup, +* this set call function in wait stait and do not freece miranda main thread +* the window is outside the desktop +*/ + +static INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) { + case WM_INITDIALOG: + LPMSGBOX pMsgBox = (LPMSGBOX)lParam; + + MoveWindow(hDlg,-10,-10,0,0,FALSE); + LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA)); + if (pmpd) { + POPUPDATAT_V2 pd = { 0 }; + pd.cbSize = sizeof(pd); + pd.lchContact = NULL; //(HANDLE)wParam; + // icon + pd.lchIcon = MsgLoadIcon(pMsgBox); + mir_tcsncpy(pd.lptzContactName, pMsgBox->ptszTitle, SIZEOF(pd.lptzContactName)); + mir_tcsncpy(pd.lptzText, pMsgBox->ptszMsg, SIZEOF(pd.lptzText)); + + // CALLBAC Proc + pd.PluginWindowProc = PopupProc; + pd.PluginData = pmpd; + pd.iSeconds = -1; + pd.lpActions = pmpd->pa; + + // set color of popup + switch (pMsgBox->uType & MB_ICONMASK) { + case MB_ICON_ERROR: + pd.colorBack = RGB(200, 10, 0); + pd.colorText = RGB(255, 255, 255); + break; + + case MB_ICON_WARNING: + pd.colorBack = RGB(200, 100, 0); + pd.colorText = RGB(255, 255, 255); + break; + + default: + if (pMsgBox->uType & MB_CUSTOMCOLOR) { + pd.colorBack = pMsgBox->colorBack; + pd.colorText = pMsgBox->colorText; + } + } + + // handle for MakePopupAction + pmpd->hDialog = hDlg; + + // active buttons + switch (MB_TYPE(pMsgBox->uType)) { + case MB_OK: + MakePopupAction(pmpd->pa[pd.actionCount++], IDOK); + break; + + case MB_OKCANCEL: + MakePopupAction(pmpd->pa[pd.actionCount++], IDOK); + MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL); + break; + + case MB_RETRYCANCEL: + MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY); + MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL); + break; + + case MB_YESNO: + MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); + MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); + break; + + case MB_ABORTRETRYIGNORE: + MakePopupAction(pmpd->pa[pd.actionCount++], IDABORT); + MakePopupAction(pmpd->pa[pd.actionCount++], IDRETRY); + MakePopupAction(pmpd->pa[pd.actionCount++], IDIGNORE); + break; + + case MB_YESNOCANCEL: + MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); + MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); + MakePopupAction(pmpd->pa[pd.actionCount++], IDCANCEL); + break; + + case MB_YESALLNO: + MakePopupAction(pmpd->pa[pd.actionCount++], IDYES); + MakePopupAction(pmpd->pa[pd.actionCount++], IDALL); + MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); + break; + } + + // create popup + CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pd, APF_NEWDATA); + if (MB_TYPE(pMsgBox->uType) == MB_OK) + EndDialog(hDlg, IDOK); + } + break; + } + return FALSE; +} + +/** +* This is the message procedure for popup +* +* @param hDlg - window handle +* @param uMsg - message to handle +* @param wParam - message specific parameter +* @param lParam - message specific parameter +* +* @return TRUE, FALSE, IDOK, IDYES, IDALL, IDNO or IDCANCEL +**/ + +static LRESULT CALLBACK PopupProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) { + case UM_POPUPACTION: + if (HIWORD(wParam) == BN_CLICKED) { + LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg); + if (pmpd) { + switch (LOWORD(wParam)) { + case IDOK: + case IDCANCEL: + case IDABORT: + case IDRETRY: + case IDIGNORE: + case IDYES: + case IDNO: + case IDALL: + case IDNONE: + if (IsWindow(pmpd->hDialog)) + EndDialog(pmpd->hDialog, LOWORD(wParam)); + break; + + default: + if (IsWindow(pmpd->hDialog)) + EndDialog(pmpd->hDialog, IDCANCEL); + } + } + PUDeletePopup(hDlg); + } + break; + + case UM_FREEPLUGINDATA: + LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg); + if (pmpd > 0) + MIR_FREE(pmpd); + return TRUE; + } + return DefWindowProc(hDlg, uMsg, wParam, lParam); +} + +/** +* This is the service function for external plugins to use the nice messagebox +* +* @param wParam - MCONTACT hContact which can display an avatar for popups +* @param lParam - MSGBOX structure holding parameters +* +* @return The function returns the ID of the clicked button (IDOK, IDCANCEL, ...) +* or -1 on error. +**/ + +INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam) +{ + LPMSGBOX pMsgBox = (LPMSGBOX)lParam; + + // check input + if ( PtrIsValid(pMsgBox) && pMsgBox->cbSize == sizeof(MSGBOX)) { + // Shall the MessageBox displayed as popup? + if (!(pMsgBox->uType & (MB_INFOBAR|MB_NOPOPUP)) && // message box can be a popup? + ServiceExists(MS_POPUP_ADDPOPUPT) && // popups exist? + myGlobals.PopupActionsExist == 1 && // popup support ext stuct? + (db_get_dw(NULL, "Popup","Actions", 0) & 1) && // popup++ actions on? + db_get_b(NULL, MODNAME, SET_POPUPMSGBOX, DEFVAL_POPUPMSGBOX)) // user likes popups? + return DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOXDUMMI), pMsgBox->hParent, MsgBoxPop, lParam); + + return DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MSGBOX), pMsgBox->hParent, MsgBoxProc, lParam); + } + return -1; +} + +/** +* name: MsgBox +* desc: calls a messagebox +* param: +**/ + +INT_PTR CALLBACK MsgBox(HWND hParent, UINT uType, LPCTSTR pszTitle, LPCTSTR pszInfo, LPCTSTR pszFormat, ...) +{ + TCHAR tszMsg[MAX_SECONDLINE]; + + va_list vl; + va_start(vl, pszFormat); + mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl); + va_end(vl); + + MSGBOX mb = {0}; + mb.cbSize = sizeof(MSGBOX); + mb.hParent = hParent; + mb.hiLogo = Skin_GetIcon(ICO_COMMON_SSWINDOW1); + mb.hiMsg = NULL; + mb.ptszTitle = TranslateTS(pszTitle); + mb.ptszInfoText = TranslateTS(pszInfo); + mb.ptszMsg = tszMsg; + mb.uType = uType; + return MsgBoxService(NULL, (LPARAM)&mb); +} + +/** +* name: MsgErr +* desc: calls a messagebox +* param: +**/ + +INT_PTR CALLBACK MsgErr(HWND hParent, LPCTSTR pszFormat, ...) +{ + TCHAR tszTitle[MAX_SECONDLINE], tszMsg[MAX_SECONDLINE]; + mir_sntprintf(tszTitle, SIZEOF(tszMsg),_T("%s - %s") ,_T(MODNAME), TranslateT("Error")); + + va_list vl; + va_start(vl, pszFormat); + mir_vsntprintf(tszMsg, SIZEOF(tszMsg), TranslateTS(pszFormat), vl); + va_end(vl); + + MSGBOX mb = {0}; + mb.cbSize = sizeof(MSGBOX); + mb.hParent = hParent; + mb.hiLogo = Skin_GetIcon(ICO_COMMON_SSWINDOW1); + mb.hiMsg = NULL; + mb.ptszTitle = tszTitle; + mb.ptszMsg = tszMsg; + mb.uType = MB_OK|MB_ICON_ERROR; + return MsgBoxService(NULL, (LPARAM)&mb); +} diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.h b/plugins/SendScreenshotPlus/src/dlg_msgbox.h index ee743f4c3c..4b8eeb1572 100644 --- a/plugins/SendScreenshotPlus/src/dlg_msgbox.h +++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.h @@ -1,5 +1,4 @@ /*
-
Miranda NG: the free IM client for Microsoft* Windows*
Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
@@ -14,18 +13,17 @@ 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
+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.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef _DLG_MSGBOX
-#define _DLG_MSGBOX 1
+#ifndef _SVC_DLG_INCLUDED_
+#define _SVC_DLG_INCLUDED_ 1
-//---------------------------------------------------------------------------
#define SET_POPUPMSGBOX "PopupMsgBox"
#define DEFVAL_POPUPMSGBOX TRUE //FALSE
@@ -54,7 +52,7 @@ Funktion returns: IDOK, IDYES, IDALL, IDNO or IDCANCEL #define MB_RETRYCANCEL 0x00000005L
*/
#define MB_YESALLNO 0x00000007L
-#define MB_TYPE(p) ((p)&MB_TYPEMASK)
+#define MB_TYPE(p) ((p)&MB_TYPEMASK)
/*
valid predefined icon values
@@ -74,27 +72,25 @@ flags #define MB_NOPOPUP 0x00000200L
#define MB_CUSTOMCOLOR 0x00000300L
-typedef struct _MSGBOX
+typedef struct _MSGBOX
{
- UINT cbSize; // size of this structure
- UINT uType; // parameters
- HICON hiLogo; // right upper icon of the info bar
- HICON hiMsg; // icon left next to the message text
- LPTSTR ptszTitle;
- LPTSTR ptszInfoText;
- LPTSTR ptszMsg;
- HWND hParent; // parent window for the messagebox
- COLORREF colorBack; // valid if MB_CUSTOMCOLOR is set
- COLORREF colorText; // valid if MB_CUSTOMCOLOR is set
+ UINT cbSize; // size of this structure
+ UINT uType; // parameters
+ HICON hiLogo; // right upper icon of the info bar
+ HICON hiMsg; // icon left next to the message text
+ LPTSTR ptszTitle;
+ LPTSTR ptszInfoText;
+ LPTSTR ptszMsg;
+ HWND hParent; // parent window for the messagebox
+ COLORREF colorBack; // valid if MB_CUSTOMCOLOR is set
+ COLORREF colorText; // valid if MB_CUSTOMCOLOR is set
} MSGBOX, *LPMSGBOX;
-INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-INT_PTR CALLBACK MsgBoxPop (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-LRESULT CALLBACK PopupProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK MsgBox(HWND hParent, UINT uType, LPCTSTR pszTitle, LPCTSTR pszInfo, LPCTSTR pszFormat, ...);
+INT_PTR CALLBACK MsgErr(HWND hParent, LPCTSTR pszFormat, ...);
+INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam);
-INT_PTR MsgBoxService(WPARAM wParam, LPARAM lParam);
-INT_PTR MsgBox(HWND hParent, UINT uType, LPTSTR pszTitle, LPTSTR pszInfo, LPTSTR pszFormat, ...);
-INT_PTR MsgErr(HWND hParent, LPCTSTR pszFormat, ...);
+LRESULT CALLBACK PopupProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-#endif /* _DLG_MSGBOX */
\ No newline at end of file +#endif /* _SVC_DLG_INCLUDED_ */
\ No newline at end of file diff --git a/plugins/SendScreenshotPlus/src/global.h b/plugins/SendScreenshotPlus/src/global.h index 9836d32e11..b643f94c15 100644 --- a/plugins/SendScreenshotPlus/src/global.h +++ b/plugins/SendScreenshotPlus/src/global.h @@ -103,7 +103,7 @@ using namespace std; #define MSGINFO (text) MessageBox(NULL, text, _T("SendSS"), MB_OK | MB_ICONINFORMATION) typedef struct _MGLOBAL { - DWORD mirandaVersion; // mirandaVersion + DWORD mirandaVersion; // mirandaVersion BOOLEAN PopupExist : 1; // Popup or MS_POPUP_ADDPOPUP exist BOOLEAN PopupActionsExist : 1; // Popup++ or MS_POPUP_REGISTERACTIONS exist BOOLEAN PluginHTTPExist : 1; // HTTPServer or MS_HTTP_ACCEPT_CONNECTIONS exist @@ -123,6 +123,7 @@ extern MGLOBAL myGlobals; extern HANDLE hNetlibUser; #define PtrIsValid(p) (((p)!=0)&&(((HANDLE)(p))!=INVALID_HANDLE_VALUE)) +#define MIR_FREE(p) {if (PtrIsValid(p)){mir_free((void*)p);(p)=NULL;}} template<class _Elem> std::basic_string<_Elem> replace(const std::basic_string<_Elem> & Origninal, const std::basic_string<_Elem> & What, const std::basic_string<_Elem> & With) diff --git a/plugins/SendScreenshotPlus/src/mir_icolib.cpp b/plugins/SendScreenshotPlus/src/mir_icolib.cpp index b7f3a48ea8..f1ea82c0ca 100644 --- a/plugins/SendScreenshotPlus/src/mir_icolib.cpp +++ b/plugins/SendScreenshotPlus/src/mir_icolib.cpp @@ -1,172 +1,156 @@ -/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
-Copyright (c) 2000-09 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.
-
-this file is taken from UserinfoEx plugin and support UserinfoEx icon pack !!!!
-
-*/
-
-#include "global.h"
-
-HICON ghDefIcon = NULL;
-
-//IDI_PLUG_MAIN must be the first icon from Plugin.dll, all other icon must be IDI_PLUG_MAIN+n
-
-struct
-{
- LPSTR pszName;
- LPSTR pszDesc;
- LPSTR pszSection;
- WORD idResource;
- BYTE size;
-}
-static icoDesc[] =
-{
- // common
- { ICO_PLUG_SSWINDOW1, LPGEN("Screenshot Icon1"), SECT_COMMON, IDI_PLUG_MAIN, -1 },
- { ICO_PLUG_SSWINDOW2, LPGEN("Screenshot Icon2"), SECT_COMMON, IDI_PLUG_ICON1, 0 },
- { ICO_PLUG_SSTARGET, LPGEN("Target Cursor"), SECT_COMMON, IDI_PLUG_ICON2, 1 },
- { ICO_PLUG_SSMONITOR, LPGEN("Target Desktop"), SECT_COMMON, IDI_PLUG_ICON3, 1 },
- { ICO_PLUG_SSDEFAULT, LPGEN("Default"), SECT_COMMON, IDI_PLUG_DEFAULT, 0 },
-
- // overlays
- { ICO_PLUG_OVERLAYON, LPGEN("Overlay on"), SECT_OVERLAY, IDI_PLUG_OVERLAYON, 0 },
- { ICO_PLUG_OVERLAYOFF, LPGEN("Overlay off"), SECT_OVERLAY, IDI_PLUG_OVERLAYOFF, 0 },
-
- // button icons
- { ICO_PLUG_SSHELP, LPGEN("Help"), SECT_BUTTONS, IDI_PLUG_HELP, 0 },
- { ICO_PLUG_SSFOLDERO, LPGEN("Open Folder"), SECT_BUTTONS, IDI_PLUG_FOLDERO, 0 },
- { ICO_PLUG_SSDESKOFF, LPGEN("Description off"), SECT_BUTTONS, IDI_PLUG_DESKOFF, 0 },
- { ICO_PLUG_SSDESKON, LPGEN("Description on"), SECT_BUTTONS, IDI_PLUG_DESKON, 0 },
- { ICO_PLUG_SSDELOFF, LPGEN("Delete off"), SECT_BUTTONS, IDI_PLUG_DELOFF, 0 },
- { ICO_PLUG_SSDELON, LPGEN("Delete on"), SECT_BUTTONS, IDI_PLUG_DELON, 0 },
- { ICO_PLUG_ARROWL, LPGEN("Prev"), SECT_BUTTONS, IDI_PLUG_ARROWL, 0 },
- { ICO_PLUG_ARROWR, LPGEN("Next"), SECT_BUTTONS, IDI_PLUG_ARROWR, 0 },
- { ICO_PLUG_UPDATE, LPGEN("Update"), SECT_BUTTONS, IDI_PLUG_UPDATE, 0 },
- { ICO_PLUG_OK, LPGEN("OK"), SECT_BUTTONS, IDI_PLUG_OK, 0 },
- { ICO_PLUG_CANCEL, LPGEN("Cancel"), SECT_BUTTONS, IDI_PLUG_CLOSE, 0 },
- { ICO_PLUG_APPLY, LPGEN("Apply"), SECT_BUTTONS, IDI_PLUG_APPLY, 0 },
- { ICO_PLUG_EDIT, LPGEN("Edit"), SECT_BUTTONS, IDI_PLUG_EDIT, 0 },
- { ICO_PLUG_DOWNARROW, LPGEN("Down arrow"), SECT_BUTTONS, IDI_PLUG_DOWNARROW, 0 },
-};
-
-/**
- * Returns a icon, identified by a name
- *
- * @param pszIcon - name of the icon
- *
- * @return: HICON if the icon is loaded, NULL otherwise
- **/
-HICON IcoLib_GetIcon(LPCSTR pszIcon, bool big)
-{
- return (pszIcon) ? Skin_GetIcon(pszIcon, big) : NULL;
-}
-
-/**
- * This function manually registers a single icon from the default icon library.
- *
- * @param szIconID - This is the uniquely identifying string for an icon.
- * This string is the setting name in the database and should
- * only use ASCII characters.
- * @param szDescription - This is the description displayed in the options dialog.
- * @param szSection - This is the subsection, where the icon is organized in the options dialog.
- * @param szDefaultFile - This is the validated path to the default icon file.
- * @param idIcon - This is the ResourceID of the icon in the default file.
- * @param Size - This is the desired size of the icon to load.
- * 0: default size for small icons (16x16)
- * 1: default size for normal icons (32x32)
- * @param hDefIcon - This is the default icon to use if the default icon
- * file does not exist and no custom icon is set up in the config.
- *
- * @return This function returns the HANDLE of the icon item.
- **/
-
-static HANDLE IcoLib_RegisterIconHandleEx(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, LPTSTR szDefaultFile, INT idIcon, INT Size, HICON hDefIcon)
-{
- if (!szIconID || !szDescription || !szSection)
- return NULL;
-
- SKINICONDESC sid = { sizeof(sid) };
- sid.flags = SIDF_ALL_TCHAR;
- sid.pszName = szIconID;
- sid.ptszDescription = mir_a2t(szDescription);
- sid.ptszSection = mir_a2t(szSection);
-
- switch (Size) {
- // small and big icons
- case -1:
- sid.cx = sid.cy = 0;
- break;
-
- // small icons (16x16)
- case 0:
- sid.cx = GetSystemMetrics(SM_CXSMICON);
- sid.cy = GetSystemMetrics(SM_CYSMICON);
- break;
-
- // normal icons (32x32)
- case 1:
- sid.cx = GetSystemMetrics(SM_CXICON);
- sid.cy = GetSystemMetrics(SM_CYICON);
- break;
-
- // custom icon size
- default:
- sid.cx = sid.cy = Size;
- break;
- }
-
- sid.ptszDefaultFile = szDefaultFile;
- if (sid.ptszDefaultFile && sid.ptszDefaultFile[0])
- sid.iDefaultIndex = idIcon - IDI_PLUG_MAIN;
- else {
- sid.hDefaultIcon = hDefIcon;
- sid.iDefaultIndex = -1;
- }
-
- HANDLE hIconHandle = Skin_AddIcon(&sid);
- mir_free(sid.ptszDescription);
- mir_free(sid.ptszSection);
- return hIconHandle;
-}
-
-/**
-* Add default icons to the skin library or load customized icons
-*
-* @param none
-*
-* @return nothing
-**/
-VOID IcoLib_LoadModule()
-{
- LPTSTR szPluginFile;
- INT_PTR i;
-
- szPluginFile = _T("Plugins\\")_T(__FILENAME);
-
- // load default icon if required
- ghDefIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_PLUG_DEFAULT), IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
-
- for (i = 0; i < SIZEOF(icoDesc); i++)
- IcoLib_RegisterIconHandleEx(icoDesc[i].pszName, icoDesc[i].pszDesc, icoDesc[i].pszSection, szPluginFile, icoDesc[i].idResource, icoDesc[i].size, ghDefIcon);
-}
+/* +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-09 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. + +this file is taken from UserinfoEx plugin and support UserinfoEx icon pack !!!! + +*/ + +#include "global.h" + +typedef struct _ICODESC +{ + LPSTR pszName; + LPSTR pszDesc; + LPSTR pszSection; + WORD idResource; + BYTE size; +} ICODESC; + +HICON ghDefIcon = NULL; + +//IDI_MAIN must be the first icon from Plugin.dll, all other icon must be IDI_MAIN+n + +static ICODESC icoDesc[] = +{ + // common + { ICO_COMMON_SSWINDOW1, LPGEN("Screenshot Icon1"), SECT_COMMON, IDI_MAIN, 1 }, + { ICO_COMMON_SSWINDOW2, LPGEN("Screenshot Icon2"), SECT_COMMON, IDI_ICON1, 0 }, + { ICO_COMMON_SSTARGET, LPGEN("Target Cursor"), SECT_COMMON, IDI_ICON2, 1 }, + { ICO_COMMON_SSMONITOR, LPGEN("Target Desktop"), SECT_COMMON, IDI_ICON3, 1 }, + { ICO_COMMON_SSDEFAULT, LPGEN("Default"), SECT_COMMON, IDI_DEFAULT, 0 }, + // overlays + { ICO_BTN_OVERLAYON, LPGEN("Overlay on"), SECT_OVERLAY, IDI_OVERLAYON, 0 }, + { ICO_BTN_OVERLAYOFF, LPGEN("Overlay off"), SECT_OVERLAY, IDI_OVERLAYOFF, 0 }, + // button icons + { ICO_COMMON_SSHELP, LPGEN("Help"), SECT_BUTTONS, IDI_HELP, 0 }, + { ICO_COMMON_SSFOLDERO, LPGEN("Open Folder"), SECT_BUTTONS, IDI_FOLDERO, 0 }, + { ICO_COMMON_SSDESKOFF, LPGEN("Description off"), SECT_BUTTONS, IDI_DESKOFF, 0 }, + { ICO_COMMON_SSDESKON, LPGEN("Description on"), SECT_BUTTONS, IDI_DESKON, 0 }, + { ICO_COMMON_SSDELOFF, LPGEN("Delete off"), SECT_BUTTONS, IDI_DELOFF, 0 }, + { ICO_COMMON_SSDELON, LPGEN("Delete on"), SECT_BUTTONS, IDI_DELON, 0 }, + { ICO_COMMON_ARROWL, LPGEN("Prev"), SECT_BUTTONS, IDI_ARROWL, 0 }, + { ICO_COMMON_ARROWR, LPGEN("Next"), SECT_BUTTONS, IDI_ARROWR, 0 }, + { ICO_BTN_UPDATE, LPGEN("Update"), SECT_BUTTONS, IDI_UPDATE, 0 }, + { ICO_BTN_OK, LPGEN("OK"), SECT_BUTTONS, IDI_OK, 0 }, + { ICO_BTN_CANCEL, LPGEN("Cancel"), SECT_BUTTONS, IDI_CLOSE, 0 }, + { ICO_BTN_APPLY, LPGEN("Apply"), SECT_BUTTONS, IDI_APPLY, 0 }, + { ICO_BTN_EDIT, LPGEN("Edit"), SECT_BUTTONS, IDI_EDIT, 0 }, + { ICO_BTN_DOWNARROW, LPGEN("Down arrow"), SECT_BUTTONS, IDI_DOWNARROW, 0 }, +}; + +/** + * This function manually registers a single icon from the default icon library. + * + * @param szIconID - This is the uniquely identifying string for an icon. + * This string is the setting name in the database and should + * only use ASCII characters. + * @param szDescription - This is the description displayed in the options dialog. + * @param szSection - This is the subsection, where the icon is organized in the options dialog. + * @param szDefaultFile - This is the validated path to the default icon file. + * @param idIcon - This is the ResourceID of the icon in the default file. + * @param Size - This is the desired size of the icon to load. + * 0: default size for small icons (16x16) + * 1: default size for normal icons (32x32) + * @param hDefIcon - This is the default icon to use if the default icon + * file does not exist and no custom icon is set up in the config. + * + * @return This function returns the HANDLE of the icon item. + **/ +static HANDLE IcoLib_RegisterIconHandleEx(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, LPTSTR szDefaultFile, int idIcon, int Size, HICON hDefIcon) +{ + HANDLE hIconHandle = NULL; + + if (szIconID && szDescription && szSection) { + SKINICONDESC sid = { sizeof(sid) }; + sid.flags = SIDF_ALL_TCHAR; + sid.pszName = szIconID; + sid.ptszDescription = mir_a2t(szDescription); + sid.ptszSection = mir_a2t(szSection); + + if (sid.ptszDescription && sid.ptszSection) { + switch (Size) { + // small icons (16x16) + case 0: + sid.cx = GetSystemMetrics(SM_CXSMICON); + sid.cy = GetSystemMetrics(SM_CYSMICON); + break; + + // normal icons (32x32) + case 1: + sid.cx = GetSystemMetrics(SM_CXICON); + sid.cy = GetSystemMetrics(SM_CYICON); + break; + + // custom icon size + default: + sid.cx = sid.cy = Size; + break; + } + + sid.ptszDefaultFile = szDefaultFile; + if (sid.ptszDefaultFile && sid.ptszDefaultFile[0]) + sid.iDefaultIndex = -idIcon; + else { + sid.hDefaultIcon = hDefIcon; + sid.iDefaultIndex = -1; + } + hIconHandle = Skin_AddIcon(&sid); + } + MIR_FREE(sid.ptszDescription); + MIR_FREE(sid.ptszSection); + } + return hIconHandle; +} + +/** + * Add default icons to the skin library or load customized icons + * + * @param none + * + * @return nothing + **/ + +//static IconItem main = { LPGEN("Main"), ICO_COMMON_MAIN, IDI_MAIN }; + +void IcoLib_LoadModule() +{ + LPTSTR szDefaultFile = _T("Plugins\\")_T(__FILENAME); + + // load default icon if required + ghDefIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_DEFAULT), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); + + for (int i = 0; i < SIZEOF(icoDesc); i++) + IcoLib_RegisterIconHandleEx( + icoDesc[i].pszName, icoDesc[i].pszDesc, icoDesc[i].pszSection, + szDefaultFile, icoDesc[i].idResource, icoDesc[i].size, ghDefIcon); +} diff --git a/plugins/SendScreenshotPlus/src/mir_icolib.h b/plugins/SendScreenshotPlus/src/mir_icolib.h index a75941519f..e1ff0a1dcf 100644 --- a/plugins/SendScreenshotPlus/src/mir_icolib.h +++ b/plugins/SendScreenshotPlus/src/mir_icolib.h @@ -1,5 +1,4 @@ /* - Miranda NG: the free IM client for Microsoft* Windows* Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org), @@ -14,14 +13,14 @@ 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 +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. - +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_ICONS_H_INCLUDED_ #define _UINFOEX_ICONS_H_INCLUDED_ 1 @@ -31,40 +30,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SECT_OVERLAY MODNAME"/"LPGEN("Overlays") // icons -#define ICO_PLUG_SSWINDOW1 MODNAME"_plug_SSwindow1" -#define ICO_PLUG_SSWINDOW2 MODNAME"_plug_SSwindow2" -#define ICO_PLUG_SSMONITOR MODNAME"_plug_SSmonitor" -#define ICO_PLUG_SSDEFAULT MODNAME"_plug_SSdefault" -#define ICO_PLUG_SSTARGET MODNAME"_plug_SSTarget" -#define ICO_PLUG_SSHELP MODNAME"_plug_SSHelp" -#define ICO_PLUG_SSFOLDERO MODNAME"_plug_SSFolderOpen" -#define ICO_PLUG_ARROWL MODNAME"_plug_SSArrowL" -#define ICO_PLUG_ARROWR MODNAME"_plug_SSArrowR" -#define ICO_PLUG_SSDESKOFF MODNAME"_plug_SSDeskOff" -#define ICO_PLUG_SSDESKON MODNAME"_plug_SSDeskOn" -#define ICO_PLUG_SSDELOFF MODNAME"_plug_SSDelOff" -#define ICO_PLUG_SSDELON MODNAME"_plug_SSDelOn" -#define ICO_PLUG_UPDATE MODNAME"_plug_update" -#define ICO_PLUG_OK MODNAME"_plug_ok" -#define ICO_PLUG_CANCEL MODNAME"_plug_cancel" -#define ICO_PLUG_APPLY MODNAME"_plug_apply" -#define ICO_PLUG_EDIT MODNAME"_plug_edit" -#define ICO_PLUG_DOWNARROW MODNAME"_plug_downarrow" - -#define ICO_PLUG_OVERLAYOFF MODNAME"_plug_SSOverlayOff" -#define ICO_PLUG_OVERLAYON MODNAME"_plug_SSOverlayOn" - +#define ICO_COMMON_SSWINDOW1 MODNAME"_plug_SSwindow1" +#define ICO_COMMON_SSWINDOW2 MODNAME"_plug_SSwindow2" +#define ICO_COMMON_SSMONITOR MODNAME"_plug_SSmonitor" +#define ICO_COMMON_SSDEFAULT MODNAME"_plug_SSdefault" +#define ICO_COMMON_SSTARGET MODNAME"_plug_SSTarget" +#define ICO_COMMON_SSHELP MODNAME"_plug_SSHelp" +#define ICO_COMMON_SSFOLDERO MODNAME"_plug_SSFolderOpen" +#define ICO_COMMON_ARROWL MODNAME"_plug_SSArrowL" +#define ICO_COMMON_ARROWR MODNAME"_plug_SSArrowR" +#define ICO_COMMON_SSDESKOFF MODNAME"_plug_SSDeskOff" +#define ICO_COMMON_SSDESKON MODNAME"_plug_SSDeskOn" +#define ICO_COMMON_SSDELOFF MODNAME"_plug_SSDelOff" +#define ICO_COMMON_SSDELON MODNAME"_plug_SSDelOn" #define ICO_DLG_DETAILS MODNAME"_dlg_details" +#define ICO_BTN_UPDATE MODNAME"_plug_update" +#define ICO_BTN_OK MODNAME"_plug_ok" +#define ICO_BTN_CANCEL MODNAME"_plug_cancel" +#define ICO_BTN_APPLY MODNAME"_plug_apply" +#define ICO_BTN_EDIT MODNAME"_plug_edit" +#define ICO_BTN_DOWNARROW MODNAME"_plug_downarrow" -/*typedef struct TIconCtrl -{ - LPCSTR pszIcon; - UINT Message; - WORD idCtrl; -} ICONCTRL, *LPICONCTRL;*/ +#define ICO_BTN_OVERLAYOFF MODNAME"_plug_SSOverlayOff" +#define ICO_BTN_OVERLAYON MODNAME"_plug_SSOverlayOn" -HICON IcoLib_GetIcon(LPCSTR pszIcon, bool big = false); -VOID IcoLib_LoadModule(); +void IcoLib_LoadModule(); #endif /* _UINFOEX_ICONS_H_INCLUDED_ */ diff --git a/plugins/SendScreenshotPlus/src/mir_string.cpp b/plugins/SendScreenshotPlus/src/mir_string.cpp index 3ac9ffca3a..e2e6c87f38 100644 --- a/plugins/SendScreenshotPlus/src/mir_string.cpp +++ b/plugins/SendScreenshotPlus/src/mir_string.cpp @@ -1,5 +1,4 @@ /*
-
Miranda NG: the free IM client for Microsoft* Windows*
Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
@@ -18,8 +17,8 @@ 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.
+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
@@ -28,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "global.h"
-wchar_t *mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest)
+wchar_t* mir_wcsncpy(wchar_t* pszDest, const wchar_t* pszSrc, const size_t cchDest)
{
if (!pszDest || !pszSrc || !cchDest)
return NULL;
@@ -37,7 +36,7 @@ wchar_t *mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDe return pszDest;
}
-wchar_t *mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest)
+wchar_t* mir_wcsncat(wchar_t* pszDest, const wchar_t* pszSrc, const size_t cchDest)
{
if (!pszDest || !pszSrc || !cchDest)
return NULL;
@@ -47,7 +46,7 @@ wchar_t *mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDe }
//---------------------------------------------------------------------------
-void mir_stradd(char* &pszDest, const char *pszSrc)
+void mir_stradd(char* &pszDest, const char* pszSrc)
{
if(!pszSrc)
return;
@@ -65,7 +64,7 @@ void mir_stradd(char* &pszDest, const char *pszSrc) }
}
-void mir_wcsadd(wchar_t* &pszDest, const wchar_t *pszSrc)
+void mir_wcsadd(wchar_t* &pszDest, const wchar_t* pszSrc)
{
if(!pszSrc)
return;
diff --git a/plugins/SendScreenshotPlus/src/mir_string.h b/plugins/SendScreenshotPlus/src/mir_string.h index 95ab3496f1..a8dc50e776 100644 --- a/plugins/SendScreenshotPlus/src/mir_string.h +++ b/plugins/SendScreenshotPlus/src/mir_string.h @@ -1,5 +1,4 @@ /*
-
Miranda NG: the free IM client for Microsoft* Windows*
Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org),
@@ -18,8 +17,8 @@ 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.
+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
@@ -29,16 +28,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _MIR_STRING_H_INCLUDED_
#define _MIR_STRING_H_INCLUDED_
-#define mir_tcsadd mir_wcsadd
-#define mir_tcsncpy mir_wcsncpy
-#define mir_tcsncat mir_wcsncat
+#define mir_tcslen mir_wcslen
+#define mir_tcsadd mir_wcsadd
+#define mir_tcsncpy mir_wcsncpy
+#define mir_tcsncat mir_wcsncat
+
+#define mir_strlen(s) (((s)!=0)?strlen(s):0)
+#define mir_strcpy(d,s) (((s)!=0&&(d)!=0)?strcpy(d,s):0)
+
+#define mir_wcslen(s) (((s)!=0)?wcslen(s):0)
-#define mir_freeAndNil(ptr) {if(ptr) mir_free(ptr); ptr = NULL;}
+#define mir_freeAndNil(ptr) mir_free(ptr),ptr=NULL
-wchar_t* mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest);
-wchar_t* mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest);
+wchar_t* mir_wcsncpy(wchar_t* pszDest, const wchar_t* pszSrc, const size_t cchDest);
+wchar_t* mir_wcsncat(wchar_t* pszDest, const wchar_t* pszSrc, const size_t cchDest);
-void mir_stradd(char * &pszDest, const char *pszSrc);
-void mir_wcsadd(wchar_t * &pszDest, const wchar_t *pszSrc);
+void mir_stradd(char* &pszDest, const char* pszSrc);
+void mir_wcsadd(wchar_t* &pszDest, const wchar_t* pszSrc);
#endif /* _MIR_STRING_H_INCLUDED_ */
\ No newline at end of file diff --git a/plugins/SendScreenshotPlus/src/resource.h b/plugins/SendScreenshotPlus/src/resource.h index 80f7ffe093..ad53242cc5 100644 --- a/plugins/SendScreenshotPlus/src/resource.h +++ b/plugins/SendScreenshotPlus/src/resource.h @@ -1,107 +1,105 @@ -//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by resource.rc
-//
-#define IDOK 1
-#define IDA_btnClose 1
-#define IDCANCEL 2
-#define IDB_Bmp1 2
-#define IDABORT 3
-#define IDB_Bmp2 3
-#define IDRETRY 4
-#define IDIGNORE 5
-#define IDYES 6
-#define IDNO 7
-#define IDCLOSE 8
-#define IDHELP 9
-#define IDTRYAGAIN 10
-#define IDCONTINUE 11
-#define IDALL 21
-#define IDD_UMainForm 101
-#define MAIN 102
-#define IDR_LICENSE 103
-#define IDD_UMain_CaptureWindow 107
-#define IDD_CAPTURE 111
-#define IDR_CREDIT 116
-#define IDI_PLUG_MAIN 190
-#define IDI_PLUG_DEFAULT 191
-#define IDI_PLUG_ICON1 192
-#define IDI_PLUG_ICON2 193
-#define IDI_PLUG_ICON3 194
-#define IDI_PLUG_HELP 195
-#define IDI_PLUG_FOLDERO 196
-#define IDI_PLUG_ARROWL 197
-#define IDI_PLUG_ARROWR 198
-#define IDI_PLUG_OVERLAYON 199
-#define IDI_PLUG_OVERLAYOFF 200
-#define IDD_UAboutForm 201
-#define IDI_PLUG_DESKOFF 201
-#define IDI_PLUG_DESKON 202
-#define IDI_PLUG_DELOFF 203
-#define IDI_PLUG_DELON 204
-#define IDI_PLUG_UPDATE 205
-#define IDI_PLUG_OK 206
-#define IDI_PLUG_CLOSE 207
-#define IDI_PLUG_APPLY 208
-#define IDI_PLUG_EDIT 209
-#define IDI_PLUG_DOWNARROW 210
-#define IDD_UEditForm 301
-#define IDC_CAPTURETAB 1005
-#define IDD_MSGBOX 1008
-#define IDC_CREDIT 1009
-#define IDD_MSGBOXDUMMI 1024
-#define IDD_UMain_CaptureDesktop 1025
-#define STATIC_WHITERECT 1100
-#define STATIC_LINE2 1103
-#define ICO_DLGLOGO 1105
-#define ICO_MSGDLG 1106
-#define TXT_NAME 1114
-#define TXT_MESSAGE 1126
-#define ID_edtCaption 1201
-#define ID_edtSize 1202
-#define ID_edtQuality 1203
-#define ID_upQuality 1204
-#define ID_edtTimed 1205
-#define ID_upTimed 1206
-#define IDC_WHITERECT 1221
-#define ID_cboxFormat 1301
-#define ID_cboxSendBy 1302
-#define ID_lblFmtInfo 1501
-#define IDE_Image 1501
-#define ID_lblSendBy 1502
-#define IDE_imgSelection 1502
-#define ID_bvlTarget 1503
-#define IDC_COPYRIGHT 1503
-#define ID_lblDropInfo 1504
-#define ID_imgTarget 1505
-#define ID_edtCaptionLabel 1506
-#define ID_edtSizeLabel 1507
-#define ID_edtQualityLabel 1508
-#define ID_edtTimedLabel 1509
-#define IDNONE 1565
-#define IDA_CONTRIBLINK 1586
-#define IDC_LICENSE 1589
-#define ID_gboxAreaToTake 1602
-#define ID_gboxOptions 1603
-#define ID_chkEditor 1701
-#define ID_chkClientArea 1704
-#define ID_chkTimed 1708
-#define ID_chkOpenAgain 1710
-#define IDC_HEADERBAR 1734
-#define ID_btnAbout 2001
-#define ID_btnExplore 2002
-#define ID_btnDesc 2003
-#define ID_btnDeleteAfterSend 2004
-#define ID_btnCapture 2005
-#define IDE_StatusBar 2501
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 123
-#define _APS_NEXT_COMMAND_VALUE 40002
-#define _APS_NEXT_CONTROL_VALUE 1011
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
+//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resource.rc +// +#define IDOK 1 +#define IDA_btnClose 1 +#define IDCANCEL 2 +#define IDB_Bmp1 2 +#define IDABORT 3 +#define IDB_Bmp2 3 +#define IDRETRY 4 +#define IDIGNORE 5 +#define IDYES 6 +#define IDNO 7 +#define IDCLOSE 8 +#define IDHELP 9 +#define IDTRYAGAIN 10 +#define IDCONTINUE 11 +#define IDALL 21 +#define IDD_UMainForm 101 +#define IDD_UMain_CaptureWindow 102 +#define IDD_UMain_CaptureDesktop 103 +#define IDD_UEditForm 104 +#define IDD_UAboutForm 105 +#define IDD_MSGBOX 110 +#define IDD_MSGBOXDUMMI 111 +#define IDR_LICENSE 120 +#define IDR_CREDIT 121 +#define IDI_MAIN 190 +#define IDI_DEFAULT 191 +#define IDI_ICON1 192 +#define IDI_ICON2 193 +#define IDI_ICON3 194 +#define IDI_HELP 195 +#define IDI_FOLDERO 196 +#define IDI_ARROWL 197 +#define IDI_ARROWR 198 +#define IDI_OVERLAYON 199 +#define IDI_OVERLAYOFF 200 +#define IDI_DESKOFF 201 +#define IDI_DESKON 202 +#define IDI_DELOFF 203 +#define IDI_DELON 204 +#define IDI_UPDATE 205 +#define IDI_OK 206 +#define IDI_CLOSE 207 +#define IDI_APPLY 208 +#define IDI_EDIT 209 +#define IDI_DOWNARROW 210 +#define IDC_CAPTURETAB 1005 +#define IDC_CREDIT 1009 +#define STATIC_WHITERECT 1100 +#define STATIC_LINE2 1103 +#define ICO_DLGLOGO 1105 +#define ICO_MSGDLG 1106 +#define TXT_NAME 1114 +#define TXT_MESSAGE 1126 +#define ID_edtCaption 1201 +#define ID_edtSize 1202 +#define ID_edtQuality 1203 +#define ID_upQuality 1204 +#define ID_edtTimed 1205 +#define ID_upTimed 1206 +#define IDC_WHITERECT 1221 +#define ID_cboxFormat 1301 +#define ID_cboxSendBy 1302 +#define ID_lblFmtInfo 1501 +#define IDE_Image 1501 +#define ID_lblSendBy 1502 +#define IDE_imgSelection 1502 +#define ID_bvlTarget 1503 +#define IDC_COPYRIGHT 1503 +#define ID_lblDropInfo 1504 +#define ID_imgTarget 1505 +#define ID_edtCaptionLabel 1506 +#define ID_edtSizeLabel 1507 +#define ID_edtQualityLabel 1508 +#define ID_edtTimedLabel 1509 +#define IDNONE 1565 +#define IDA_CONTRIBLINK 1586 +#define IDC_LICENSE 1589 +#define ID_gboxAreaToTake 1602 +#define ID_gboxOptions 1603 +#define ID_chkEditor 1701 +#define ID_chkClientArea 1704 +#define ID_chkTimed 1708 +#define ID_chkOpenAgain 1710 +#define IDC_HEADERBAR 1734 +#define ID_btnAbout 2001 +#define ID_btnExplore 2002 +#define ID_btnDesc 2003 +#define ID_btnDeleteAfterSend 2004 +#define ID_btnCapture 2005 +#define IDE_StatusBar 2501 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 123 +#define _APS_NEXT_COMMAND_VALUE 40002 +#define _APS_NEXT_CONTROL_VALUE 1011 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif |