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/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 +- 5 files changed, 6 insertions(+), 190 deletions(-) delete mode 100644 src/mir_app/src/resizer.cpp (limited to 'src/mir_app') 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); -- cgit v1.2.3