From e561d5979d38cee45609ad871ea7a7e048bbaa92 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 7 Nov 2023 12:52:41 +0300 Subject: =?UTF-8?q?fixes=20#3872=20(UInfoEx:=20=D0=B5=D1=81=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BA=D0=B0=D0=B7=D0=B0=D1=82=D1=8C=D1=81=D1=8F=20?= =?UTF-8?q?=D0=BE=D1=82=20=D1=81=D0=B1=D1=80=D0=BE=D1=81=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BA,=20=D1=82=D0=BE=20?= =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D0=B3=D0=B8=D0=BD=20=D0=B2=D1=81=D1=91=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BD=D0=BE=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89?= =?UTF-8?q?=D0=B0=D0=B5=D1=82,=20=D1=87=D1=82=D0=BE=20=D0=BE=D0=BD=D0=B8?= =?UTF-8?q?=20=D1=81=D0=B1=D1=80=D0=BE=D1=88=D0=B5=D0=BD=D1=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/UserInfoEx/src/dlg_msgbox.cpp | 52 +++++++++++++++++----------------- plugins/UserInfoEx/src/psp_options.cpp | 9 ++---- 2 files changed, 28 insertions(+), 33 deletions(-) (limited to 'plugins/UserInfoEx') diff --git a/plugins/UserInfoEx/src/dlg_msgbox.cpp b/plugins/UserInfoEx/src/dlg_msgbox.cpp index c97ac57579..e02dfb7e12 100644 --- a/plugins/UserInfoEx/src/dlg_msgbox.cpp +++ b/plugins/UserInfoEx/src/dlg_msgbox.cpp @@ -24,11 +24,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -typedef struct _MSGPOPUPDATA +struct MSGPOPUPDATA { POPUPACTION pa[3]; HWND hDialog; -} MSGPOPUPDATA, *LPMSGPOPUPDATA; +}; /** * This helper function moves and resizes a dialog box's control element. @@ -69,7 +69,7 @@ static HICON MsgLoadIcon(MSGBOX *pMsgBox) hIcon = pMsgBox->hiMsg; break; - // default windows icons + // default windows icons case MB_ICON_ERROR: case MB_ICON_QUESTION: case MB_ICON_WARNING: @@ -80,7 +80,7 @@ static HICON MsgLoadIcon(MSGBOX *pMsgBox) } break; - // no icon + // no icon default: hIcon = nullptr; } @@ -178,7 +178,7 @@ static INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l switch (uMsg) { case WM_INITDIALOG: { - MSGBOX *pMsgBox = (MSGBOX*)lParam; + MSGBOX *pMsgBox = (MSGBOX *)lParam; if (PtrIsValid(pMsgBox)) { int icoWidth = 0; int InfoBarHeight = 0; @@ -228,38 +228,38 @@ static INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l if (HDC hDC = GetDC(hDlg)) { POINT mpt = { 0, 0 }; RECT ws = { 0, 0, 0, 0 }; - int txtWidth=0, txtHeight=0, needX, needY; + int txtWidth = 0, txtHeight = 0, needX, needY; RECT rcDlg; SIZE ts; LPTSTR h, rs; SelectObject(hDC, hNormalFont); // get message text width and height - if(pMsgBox->ptszMsg) for (rs=h=pMsgBox->ptszMsg; ; ++h) { - if (*h=='\n' || !*h) { - GetTextExtentPoint32(hDC, rs, h-rs, &ts); + if (pMsgBox->ptszMsg) for (rs = h = pMsgBox->ptszMsg; ; ++h) { + if (*h == '\n' || !*h) { + GetTextExtentPoint32(hDC, rs, h - rs, &ts); if (ts.cx > txtWidth) txtWidth = ts.cx; txtHeight += ts.cy; if (!*h) break; - rs = h+1; + rs = h + 1; } } // increase width if info text requires more - if((pMsgBox->uType&MB_INFOBAR) && pMsgBox->ptszInfoText && *pMsgBox->ptszInfoText){ + if ((pMsgBox->uType & MB_INFOBAR) && pMsgBox->ptszInfoText && *pMsgBox->ptszInfoText) { //int multiline = 0; - RECT rcico; GetClientRect(GetDlgItem(hDlg,ICO_DLGLOGO), &rcico); - rcico.right = rcico.right*100/66; // padding - for(rs=h=pMsgBox->ptszInfoText; ; ++h) { - if (*h=='\n' || !*h) { - GetTextExtentPoint32(hDC, rs, h-rs, &ts); + RECT rcico; GetClientRect(GetDlgItem(hDlg, ICO_DLGLOGO), &rcico); + rcico.right = rcico.right * 100 / 66; // padding + for (rs = h = pMsgBox->ptszInfoText; ; ++h) { + if (*h == '\n' || !*h) { + GetTextExtentPoint32(hDC, rs, h - rs, &ts); ts.cx += rcico.right; if (ts.cx > txtWidth) txtWidth = ts.cx; if (!*h) break; - rs = h+1; + rs = h + 1; //++multiline; } } @@ -274,8 +274,8 @@ static INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l 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; + 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); @@ -485,10 +485,10 @@ static INT_PTR CALLBACK MsgBoxPop(HWND hDlg, UINT uMsg, WPARAM, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: - MSGBOX *pMsgBox = (MSGBOX*)lParam; + MSGBOX *pMsgBox = (MSGBOX *)lParam; MoveWindow(hDlg, -10, -10, 0, 0, FALSE); - LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA)); + MSGPOPUPDATA *pmpd = (MSGPOPUPDATA *)mir_alloc(sizeof(MSGPOPUPDATA)); if (pmpd) { POPUPDATAW ppd; ppd.lchContact = NULL; //(HANDLE)wParam; @@ -590,7 +590,7 @@ 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); + MSGPOPUPDATA *pmpd = (MSGPOPUPDATA *)PUGetPluginData(hDlg); if (pmpd) { switch (LOWORD(wParam)) { case IDOK: @@ -616,7 +616,7 @@ LRESULT CALLBACK PopupProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) break; case UM_FREEPLUGINDATA: - LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)PUGetPluginData(hDlg); + MSGPOPUPDATA *pmpd = (MSGPOPUPDATA *)PUGetPluginData(hDlg); if (pmpd > 0) MIR_FREE(pmpd); return TRUE; @@ -635,7 +635,7 @@ LRESULT CALLBACK PopupProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) **/ INT_PTR MsgBoxService(WPARAM, LPARAM lParam) { - MSGBOX *pMsgBox = (MSGBOX*)lParam; + MSGBOX *pMsgBox = (MSGBOX *)lParam; // check input if (PtrIsValid(pMsgBox) && pMsgBox->cbSize == sizeof(MSGBOX)) { @@ -664,7 +664,7 @@ INT_PTR CALLBACK MsgBox(HWND hParent, UINT uType, LPCTSTR pszTitle, LPCTSTR pszI mir_vsnwprintf(tszMsg, _countof(tszMsg), TranslateW(pszFormat), vl); va_end(vl); - MSGBOX mb = { 0 }; + MSGBOX mb = {}; mb.cbSize = sizeof(MSGBOX); mb.hParent = hParent; mb.hiLogo = g_plugin.getIcon(IDI_MAIN); @@ -691,7 +691,7 @@ INT_PTR CALLBACK MsgErr(HWND hParent, LPCTSTR pszFormat, ...) mir_vsnwprintf(tszMsg, TranslateW(pszFormat), vl); va_end(vl); - MSGBOX mb = {0}; + MSGBOX mb = {}; mb.cbSize = sizeof(MSGBOX); mb.hParent = hParent; mb.hiLogo = g_plugin.getIcon(IDI_MAIN); diff --git a/plugins/UserInfoEx/src/psp_options.cpp b/plugins/UserInfoEx/src/psp_options.cpp index 7399537e1f..c065e953d4 100644 --- a/plugins/UserInfoEx/src/psp_options.cpp +++ b/plugins/UserInfoEx/src/psp_options.cpp @@ -202,13 +202,8 @@ public: void onClick_Reset(CCtrlButton *) { - uint8_t WantReset = MsgBox(m_hwnd, - MB_ICON_WARNING | MB_YESNO, - LPGENW("Question"), - LPGENW("Reset factory defaults"), - LPGENW("This will delete all settings, you've made!\nAll TreeView settings, window positions and any other settings!\n\nAre you sure to proceed?")); - - if (!WantReset) + if (IDYES != MsgBox(m_hwnd, MB_ICON_WARNING | MB_YESNO, LPGENW("Question"), LPGENW("Reset factory defaults"), + LPGENW("This will delete all settings, you've made!\nAll TreeView settings, window positions and any other settings!\n\nAre you sure to proceed?"))) return; DB::CEnumList Settings; -- cgit v1.2.3