From e865872b4ef16b6e40cfe868843f1070fa3a239b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 21 Jun 2015 12:01:49 +0000 Subject: - resizer moved to mir_core, because it uses hard-coded windows structures; - MS_UTILS_RESIZEDIALOG replaced with a short call of Utils_ResizeDialog; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@14295 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdchat/src/window.cpp | 8 +- src/core/stdfile/src/filexferdlg.cpp | 11 +-- src/core/stdmsg/src/msgdialog.cpp | 8 +- src/core/stduihist/src/history.cpp | 11 +-- src/mir_app/src/enterstring.cpp | 10 +-- src/mir_app/src/findadd.cpp | 9 +- src/mir_app/src/resizer.cpp | 158 ----------------------------------- src/mir_app/src/skin2opts.cpp | 12 +-- src/mir_app/src/utils.cpp | 7 +- src/mir_core/src/mir_core.def | 1 + src/mir_core/src/mir_core64.def | 1 + src/mir_core/src/resizer.cpp | 151 +++++++++++++++++++++++++++++++++ src/mir_core/src/ui_utils.cpp | 12 +-- 13 files changed, 166 insertions(+), 233 deletions(-) delete mode 100644 src/mir_app/src/resizer.cpp create mode 100644 src/mir_core/src/resizer.cpp (limited to 'src') diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index 8bc99cbc52..13dc4c0497 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -1426,13 +1426,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) if (!IsIconic(hwndDlg)) { SendMessage(si->hwndStatus, WM_SIZE, 0, 0); - UTILRESIZEDIALOG urd = { sizeof(urd) }; - urd.hInstance = g_hInst; - urd.hwndDlg = hwndDlg; - urd.lParam = (LPARAM)si; - urd.lpTemplate = MAKEINTRESOURCEA(IDD_CHANNEL); - urd.pfnResizer = RoomWndResize; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); + Utils_ResizeDialog(hwndDlg, g_hInst, MAKEINTRESOURCEA(IDD_CHANNEL), RoomWndResize, (LPARAM)si); InvalidateRect(si->hwndStatus, NULL, TRUE); RedrawWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), NULL, NULL, RDW_INVALIDATE); diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp index 3e5976e08a..a256f7316e 100644 --- a/src/core/stdfile/src/filexferdlg.cpp +++ b/src/core/stdfile/src/filexferdlg.cpp @@ -711,15 +711,8 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; case WM_SIZE: - { - UTILRESIZEDIALOG urd = { 0 }; - urd.cbSize = sizeof(urd); - urd.hwndDlg = hwndDlg; - urd.hInstance = hInst; - urd.lpTemplate = MAKEINTRESOURCEA(IDD_FILETRANSFERINFO); - urd.pfnResizer = FileTransferDlgResizer; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - } + Utils_ResizeDialog(hwndDlg, hInst, MAKEINTRESOURCEA(IDD_FILETRANSFERINFO), FileTransferDlgResizer); + RedrawWindow(GetDlgItem(hwndDlg, IDC_ALLTRANSFERRED), NULL, NULL, RDW_INVALIDATE | RDW_NOERASE); RedrawWindow(GetDlgItem(hwndDlg, IDC_ALLSPEED), NULL, NULL, RDW_INVALIDATE | RDW_NOERASE); RedrawWindow(GetDlgItem(hwndDlg, IDC_CONTACTNAME), NULL, NULL, RDW_INVALIDATE | RDW_NOERASE); diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index eaa26e309d..583f6acd8d 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -1151,13 +1151,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP bottomScroll = (si.nPos + (int)si.nPage + 5) >= si.nMax; } - UTILRESIZEDIALOG urd = { sizeof(urd) }; - urd.hInstance = g_hInst; - urd.hwndDlg = hwndDlg; - urd.lParam = (LPARAM)dat; - urd.lpTemplate = MAKEINTRESOURCEA(IDD_MSG); - urd.pfnResizer = MessageDialogResize; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)& urd); + Utils_ResizeDialog(hwndDlg, g_hInst, MAKEINTRESOURCEA(IDD_MSG), MessageDialogResize, (LPARAM)dat); // The statusbar sometimes draws over these 2 controls so // redraw them diff --git a/src/core/stduihist/src/history.cpp b/src/core/stduihist/src/history.cpp index 78ed1a68e8..12add45b25 100644 --- a/src/core/stduihist/src/history.cpp +++ b/src/core/stduihist/src/history.cpp @@ -237,16 +237,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; case WM_SIZE: - { - UTILRESIZEDIALOG urd = { 0 }; - urd.cbSize = sizeof(urd); - urd.hwndDlg = hwndDlg; - urd.hInstance = hInst; - urd.lpTemplate = MAKEINTRESOURCEA(IDD_HISTORY); - urd.lParam = 0; - urd.pfnResizer = HistoryDlgResizer; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - } + Utils_ResizeDialog(hwndDlg, hInst, MAKEINTRESOURCEA(IDD_HISTORY), HistoryDlgResizer); return TRUE; case WM_COMMAND: diff --git a/src/mir_app/src/enterstring.cpp b/src/mir_app/src/enterstring.cpp index 4179741bbb..d1d42ab4cc 100644 --- a/src/mir_app/src/enterstring.cpp +++ b/src/mir_app/src/enterstring.cpp @@ -173,15 +173,7 @@ static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa return TRUE; case WM_SIZE: - { - UTILRESIZEDIALOG urd = { 0 }; - urd.cbSize = sizeof(urd); - urd.hInstance = g_hInst; - urd.hwndDlg = hwndDlg; - urd.lpTemplate = MAKEINTRESOURCEA(IDD_ENTER_STRING); - urd.pfnResizer = sttEnterStringResizer; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - } + Utils_ResizeDialog(hwndDlg, g_hInst, MAKEINTRESOURCEA(IDD_ENTER_STRING), sttEnterStringResizer); break; case WM_GETMINMAXINFO: diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp index db81e02da2..5186f627c7 100644 --- a/src/mir_app/src/findadd.cpp +++ b/src/mir_app/src/findadd.cpp @@ -436,14 +436,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_SIZE: { - UTILRESIZEDIALOG urd = { 0 }; - urd.cbSize = sizeof(urd); - urd.hwndDlg = hwndDlg; - urd.hInstance = g_hInst; - urd.lpTemplate = MAKEINTRESOURCEA(IDD_FINDADD); - urd.lParam = (LPARAM)dat; - urd.pfnResizer = FindAddDlgResizer; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); + Utils_ResizeDialog(hwndDlg, g_hInst, MAKEINTRESOURCEA(IDD_FINDADD), FindAddDlgResizer, (LPARAM)dat); ReposTinySearchDlg(hwndDlg, dat); SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_SIZE, 0, 0); if (dat->notSearchedYet) { diff --git a/src/mir_app/src/resizer.cpp b/src/mir_app/src/resizer.cpp deleted file mode 100644 index ce27ee8079..0000000000 --- a/src/mir_app/src/resizer.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-12 Miranda 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 "stdafx.h" - -#pragma pack(2) - -typedef struct { - DWORD helpID; - DWORD exStyle; - DWORD style; - short x; - short y; - short cx; - short cy; - DWORD id; -} START_OF_DLGITEMTEMPLATEEX; - -typedef struct { - WORD dlgVer; - WORD signature; - DWORD helpID; - DWORD exStyle; - DWORD style; - WORD cDlgItems; - short x; - short y; - short cx; - short cy; -} START_OF_DLGTEMPLATEEX; - -INT_PTR ResizeDialog(WPARAM, LPARAM lParam) -{ - UTILRESIZEDIALOG *urd = (UTILRESIZEDIALOG*)lParam; - HDWP hDwp; - int i; - DLGITEMTEMPLATE *pItem = NULL; - START_OF_DLGITEMTEMPLATEEX *pItemEx = NULL; - RECT rc; - PWORD pWord; - DLGTEMPLATE *pTemplate; - START_OF_DLGTEMPLATEEX *pTemplateEx; - UTILRESIZECONTROL urc; - int procResult; - int extendedDlg, itemCount; - - if (urd == NULL || urd->cbSize != sizeof(UTILRESIZEDIALOG)) return 1; - pTemplate = (DLGTEMPLATE*)LockResource(LoadResource(urd->hInstance, FindResourceA(urd->hInstance, urd->lpTemplate, MAKEINTRESOURCEA(5)))); - pTemplateEx = (START_OF_DLGTEMPLATEEX*)pTemplate; - extendedDlg = pTemplateEx->signature == 0xFFFF; - if (extendedDlg && pTemplateEx->dlgVer != 1) - return 1; - - if (extendedDlg) pWord = (PWORD)(pTemplateEx+1); - else pWord = (PWORD)(pTemplate+1); - if (*pWord == 0xFFFF) pWord+=2; else while (*pWord++); //menu - if (*pWord == 0xFFFF) pWord+=2; else while (*pWord++); //class - while (*pWord++); //title - if (extendedDlg) { - if (pTemplateEx->style&DS_SETFONT) { - pWord+=3; //font size, weight, italic - while (*pWord++); //font name - } - } - else { - if (pTemplate->style&DS_SETFONT) { - pWord++; //font size - while (*pWord++); //font name - } - } - - urc.cbSize = sizeof(UTILRESIZECONTROL); - rc.left = 0; rc.top = 0; - if (extendedDlg) {rc.right = pTemplateEx->cx; rc.bottom = pTemplateEx->cy;} - else {rc.right = pTemplate->cx; rc.bottom = pTemplate->cy;} - MapDialogRect(urd->hwndDlg, &rc); - urc.dlgOriginalSize.cx = rc.right; urc.dlgOriginalSize.cy = rc.bottom; - GetClientRect(urd->hwndDlg, &rc); - urc.dlgNewSize.cx = rc.right; urc.dlgNewSize.cy = rc.bottom; - - if (extendedDlg) itemCount = pTemplateEx->cDlgItems; - else itemCount = pTemplate->cdit; - hDwp = BeginDeferWindowPos(itemCount); - for (i=0;iid; - urc.rcItem.left = pItemEx->x; urc.rcItem.top = pItemEx->y; - urc.rcItem.right = urc.rcItem.left+pItemEx->cx; urc.rcItem.bottom = urc.rcItem.top+pItemEx->cy; - } - else { - pItem = (DLGITEMTEMPLATE*)pWord; - pWord = (PWORD)(pItem+1); - - urc.wId = pItem->id; - urc.rcItem.left = pItem->x; urc.rcItem.top = pItem->y; - urc.rcItem.right = urc.rcItem.left+pItem->cx; urc.rcItem.bottom = urc.rcItem.top+pItem->cy; - } - if (*pWord == 0xFFFF) pWord+=2; else while (*pWord++); //menu - if (*pWord == 0xFFFF) pWord+=2; else while (*pWord++); //class - pWord+=1+(1+*pWord)/2; //creation data - - if (urc.wId == 65535) continue; //using this breaks the dwp, so just ignore it - - MapDialogRect(urd->hwndDlg, &urc.rcItem); - procResult = (urd->pfnResizer)(urd->hwndDlg, urd->lParam, &urc); - if (procResult&RD_ANCHORX_RIGHT) { - urc.rcItem.left+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; - urc.rcItem.right+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; - } - else if (procResult&RD_ANCHORX_WIDTH) - urc.rcItem.right+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; - else if (procResult&RD_ANCHORX_CENTRE) { - urc.rcItem.left+=(urc.dlgNewSize.cx-urc.dlgOriginalSize.cx)/2; - urc.rcItem.right+=(urc.dlgNewSize.cx-urc.dlgOriginalSize.cx)/2; - } - if (procResult&RD_ANCHORY_BOTTOM) { - urc.rcItem.top+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; - urc.rcItem.bottom+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; - } - else if (procResult&RD_ANCHORY_HEIGHT) - urc.rcItem.bottom+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; - else if (procResult&RD_ANCHORY_CENTRE) { - urc.rcItem.top+=(urc.dlgNewSize.cy-urc.dlgOriginalSize.cy)/2; - urc.rcItem.bottom+=(urc.dlgNewSize.cy-urc.dlgOriginalSize.cy)/2; - } - HWND hCtrl = GetDlgItem(urd->hwndDlg, extendedDlg ? pItemEx->id : pItem->id); - if (NULL != hCtrl) /* Wine fix. */ - hDwp = DeferWindowPos(hDwp, hCtrl, 0, urc.rcItem.left, urc.rcItem.top, urc.rcItem.right-urc.rcItem.left, urc.rcItem.bottom-urc.rcItem.top, SWP_NOZORDER); - } - EndDeferWindowPos(hDwp); - return 0; -} diff --git a/src/mir_app/src/skin2opts.cpp b/src/mir_app/src/skin2opts.cpp index b33c2fc876..194a2a7696 100644 --- a/src/mir_app/src/skin2opts.cpp +++ b/src/mir_app/src/skin2opts.cpp @@ -553,16 +553,8 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break; case WM_SIZE: // make the dlg resizeable - if (!IsIconic(hwndDlg)) { - UTILRESIZEDIALOG urd = { 0 }; - urd.cbSize = sizeof(urd); - urd.hInstance = g_hInst; - urd.hwndDlg = hwndDlg; - urd.lParam = 0; // user-defined - urd.lpTemplate = MAKEINTRESOURCEA(IDD_ICOLIB_IMPORT); - urd.pfnResizer = IconDlg_Resize; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - } + if (!IsIconic(hwndDlg)) + Utils_ResizeDialog(hwndDlg, g_hInst, MAKEINTRESOURCEA(IDD_ICOLIB_IMPORT), IconDlg_Resize); break; case WM_CLOSE: diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp index a383bbaf2f..6022c3e87f 100644 --- a/src/mir_app/src/utils.cpp +++ b/src/mir_app/src/utils.cpp @@ -349,11 +349,9 @@ static INT_PTR GenerateRandom(WPARAM wParam, LPARAM lParam) PGENRANDOM pfnRtlGenRandom = NULL; HMODULE hModule = GetModuleHandleA("advapi32"); - if (hModule) - { + if (hModule) { pfnRtlGenRandom = (PGENRANDOM)GetProcAddress(hModule, "SystemFunction036"); - if (pfnRtlGenRandom) - { + if (pfnRtlGenRandom) { if (!pfnRtlGenRandom((PVOID)lParam, wParam)) pfnRtlGenRandom = NULL; } @@ -367,7 +365,6 @@ int LoadUtilsModule(void) { bModuleInitialized = TRUE; - CreateServiceFunction(MS_UTILS_RESIZEDIALOG, ResizeDialog); CreateServiceFunction(MS_UTILS_GETCOUNTRYBYNUMBER, GetCountryByNumber); CreateServiceFunction(MS_UTILS_GETCOUNTRYBYISOCODE, GetCountryByISOCode); CreateServiceFunction(MS_UTILS_GETCOUNTRYLIST, GetCountryList); diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index de7e3dba81..a86369bacb 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -969,3 +969,4 @@ TimeZone_ToLocal @1126 TimeZone_ToString @1127 TimeZone_ToStringW @1128 TimeZone_UtcToLocal @1129 +Utils_ResizeDialog @1130 diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index d827389424..0bf6458503 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -969,3 +969,4 @@ TimeZone_ToLocal @1126 TimeZone_ToString @1127 TimeZone_ToStringW @1128 TimeZone_UtcToLocal @1129 +Utils_ResizeDialog @1130 diff --git a/src/mir_core/src/resizer.cpp b/src/mir_core/src/resizer.cpp new file mode 100644 index 0000000000..cd212fdb4a --- /dev/null +++ b/src/mir_core/src/resizer.cpp @@ -0,0 +1,151 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-12 Miranda 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 "stdafx.h" + +#pragma pack(2) + +struct START_OF_DLGITEMTEMPLATEEX +{ + DWORD helpID; + DWORD exStyle; + DWORD style; + short x, y, cx, cy; + DWORD id; +}; + +struct START_OF_DLGTEMPLATEEX +{ + WORD dlgVer; + WORD signature; + DWORD helpID; + DWORD exStyle; + DWORD style; + WORD cDlgItems; + short x, y, cx, cy; +}; + +MIR_CORE_DLL(int) Utils_ResizeDialog(HWND hwndDlg, HINSTANCE hInstance, LPCSTR lpTemplate, DIALOGRESIZERPROC pfnResizer, LPARAM lParam) +{ + DLGTEMPLATE *pTemplate = (DLGTEMPLATE*)LockResource(LoadResource(hInstance, FindResourceA(hInstance, lpTemplate, MAKEINTRESOURCEA(5)))); + START_OF_DLGTEMPLATEEX *pTemplateEx = (START_OF_DLGTEMPLATEEX*)pTemplate; + int extendedDlg = pTemplateEx->signature == 0xFFFF; + if (extendedDlg && pTemplateEx->dlgVer != 1) + return 1; + + PWORD pWord = (extendedDlg) ? (PWORD)(pTemplateEx + 1) : (PWORD)(pTemplate + 1); + if (*pWord == 0xFFFF) pWord += 2; else while (*pWord++); // menu + if (*pWord == 0xFFFF) pWord += 2; else while (*pWord++); // class + while (*pWord++); // skip title + if (extendedDlg) { + if (pTemplateEx->style & DS_SETFONT) { + pWord += 3; // font size, weight, italic + while (*pWord++); // font name + } + } + else { + if (pTemplate->style & DS_SETFONT) { + pWord++; // font size + while (*pWord++); // font name + } + } + + UTILRESIZECONTROL urc; + urc.cbSize = sizeof(UTILRESIZECONTROL); + + RECT rc; + rc.left = 0; rc.top = 0; + if (extendedDlg) { + rc.right = pTemplateEx->cx; + rc.bottom = pTemplateEx->cy; + } + else { + rc.right = pTemplate->cx; + rc.bottom = pTemplate->cy; + } + + MapDialogRect(hwndDlg, &rc); + urc.dlgOriginalSize.cx = rc.right; urc.dlgOriginalSize.cy = rc.bottom; + GetClientRect(hwndDlg, &rc); + urc.dlgNewSize.cx = rc.right; urc.dlgNewSize.cy = rc.bottom; + + int itemCount = (extendedDlg) ? pTemplateEx->cDlgItems : pTemplate->cdit; + + HDWP hDwp = BeginDeferWindowPos(itemCount); + for (int i = 0; i < itemCount; i++) { + if ((UINT_PTR)pWord & 2) pWord++; //dword align + + if (extendedDlg) { + START_OF_DLGITEMTEMPLATEEX *pItemEx = (START_OF_DLGITEMTEMPLATEEX*)pWord; + pWord = (PWORD)(pItemEx + 1); + + urc.wId = pItemEx->id; + urc.rcItem.left = pItemEx->x; urc.rcItem.top = pItemEx->y; + urc.rcItem.right = urc.rcItem.left + pItemEx->cx; urc.rcItem.bottom = urc.rcItem.top + pItemEx->cy; + } + else { + DLGITEMTEMPLATE *pItem = (DLGITEMTEMPLATE*)pWord; + pWord = (PWORD)(pItem + 1); + + urc.wId = pItem->id; + urc.rcItem.left = pItem->x; urc.rcItem.top = pItem->y; + urc.rcItem.right = urc.rcItem.left + pItem->cx; urc.rcItem.bottom = urc.rcItem.top + pItem->cy; + } + if (*pWord == 0xFFFF) pWord += 2; else while (*pWord++); // menu + if (*pWord == 0xFFFF) pWord += 2; else while (*pWord++); // class + pWord += 1 + (1 + *pWord) / 2; //creation data + + if (urc.wId == 65535) // using this breaks the dwp, so just ignore it + continue; + + MapDialogRect(hwndDlg, &urc.rcItem); + int procResult = (pfnResizer)(hwndDlg, lParam, &urc); + if (procResult & RD_ANCHORX_RIGHT) { + urc.rcItem.left += urc.dlgNewSize.cx - urc.dlgOriginalSize.cx; + urc.rcItem.right += urc.dlgNewSize.cx - urc.dlgOriginalSize.cx; + } + else if (procResult & RD_ANCHORX_WIDTH) + urc.rcItem.right += urc.dlgNewSize.cx - urc.dlgOriginalSize.cx; + else if (procResult & RD_ANCHORX_CENTRE) { + urc.rcItem.left += (urc.dlgNewSize.cx - urc.dlgOriginalSize.cx) / 2; + urc.rcItem.right += (urc.dlgNewSize.cx - urc.dlgOriginalSize.cx) / 2; + } + if (procResult & RD_ANCHORY_BOTTOM) { + urc.rcItem.top += urc.dlgNewSize.cy - urc.dlgOriginalSize.cy; + urc.rcItem.bottom += urc.dlgNewSize.cy - urc.dlgOriginalSize.cy; + } + else if (procResult & RD_ANCHORY_HEIGHT) + urc.rcItem.bottom += urc.dlgNewSize.cy - urc.dlgOriginalSize.cy; + else if (procResult & RD_ANCHORY_CENTRE) { + urc.rcItem.top += (urc.dlgNewSize.cy - urc.dlgOriginalSize.cy) / 2; + urc.rcItem.bottom += (urc.dlgNewSize.cy - urc.dlgOriginalSize.cy) / 2; + } + + HWND hCtrl = GetDlgItem(hwndDlg, urc.wId); + if (hCtrl != NULL) + hDwp = DeferWindowPos(hDwp, hCtrl, 0, urc.rcItem.left, urc.rcItem.top, urc.rcItem.right - urc.rcItem.left, urc.rcItem.bottom - urc.rcItem.top, SWP_NOZORDER); + } + EndDeferWindowPos(hDwp); + return 0; +} diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp index f786afe73a..8074461f26 100644 --- a/src/mir_core/src/ui_utils.cpp +++ b/src/mir_core/src/ui_utils.cpp @@ -189,16 +189,8 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) return FALSE; case WM_SIZE: - if (m_forceResizable || (GetWindowLongPtr(m_hwnd, GWL_STYLE) & WS_SIZEBOX)) { - UTILRESIZEDIALOG urd; - urd.cbSize = sizeof(urd); - urd.hwndDlg = m_hwnd; - urd.hInstance = m_hInst; - urd.lpTemplate = MAKEINTRESOURCEA(m_idDialog); - urd.lParam = 0; - urd.pfnResizer = GlobalDlgResizer; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - } + if (m_forceResizable || (GetWindowLongPtr(m_hwnd, GWL_STYLE) & WS_SIZEBOX)) + Utils_ResizeDialog(m_hwnd, m_hInst, MAKEINTRESOURCEA(m_idDialog), GlobalDlgResizer); return TRUE; case WM_CLOSE: -- cgit v1.2.3