From a75ce08f5ea46237b73e5052a956829c0e272678 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 17 Jun 2015 17:03:45 +0000 Subject: minus MS_UTILS_SAVEWINDOWPOSITION & MS_UTILS_RESTOREWINDOWPOSITION git-svn-id: http://svn.miranda-ng.org/main/trunk@14238 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_app/src/clistmod.cpp | 2 +- src/mir_app/src/clui.cpp | 4 +- src/mir_app/src/miranda.h | 1 - src/mir_app/src/utils.cpp | 96 -------------------------------------------- 4 files changed, 3 insertions(+), 100 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index b124fffe8f..1b11108836 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -389,7 +389,7 @@ int fnShowHide(WPARAM, LPARAM) //this forces the window onto the visible screen GetWindowRect(cli.hwndContactList, &rcWindow); - if (AssertInsideScreen(rcWindow) == 1) { + if (Utils_AssertInsideScreen(&rcWindow) == 1) { MoveWindow(cli.hwndContactList, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE); } diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index 0ee56992a9..773e68fb5b 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -291,7 +291,7 @@ int LoadCLUIModule(void) pos.right = pos.left + (int)db_get_dw(NULL, "CList", "Width", 108); pos.bottom = pos.top + (int)db_get_dw(NULL, "CList", "Height", 310); - AssertInsideScreen(pos); + Utils_AssertInsideScreen(&pos); cli.hwndContactList = CreateWindowEx( (db_get_b(NULL, "CList", "ToolWindow", SETTING_TOOLWINDOW_DEFAULT) ? WS_EX_TOOLWINDOW : WS_EX_APPWINDOW), @@ -750,7 +750,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM { RECT rc; GetWindowRect(hwnd, &rc); - if (AssertInsideScreen(rc) == 1) + if (Utils_AssertInsideScreen(&rc) == 1) MoveWindow(hwnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); } return DefWindowProc(hwnd, msg, wParam, lParam); diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index eceac3e7c0..174a79d2ca 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -172,7 +172,6 @@ INT_PTR CallProtoServiceInt(MCONTACT hContact, const char* szModule, const char* void HotkeyToName(TCHAR *buf, int size, BYTE shift, BYTE key); WORD GetHotkeyValue(INT_PTR idHotkey); -int AssertInsideScreen(RECT &rc); HBITMAP ConvertIconToBitmap(HICON hIcon, HIMAGELIST hIml, int iconId); diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp index cebebc6e5f..2b96d5f4cf 100644 --- a/src/mir_app/src/utils.cpp +++ b/src/mir_app/src/utils.cpp @@ -325,99 +325,6 @@ static INT_PTR GetCountryList(WPARAM wParam, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// -static INT_PTR SaveWindowPosition(WPARAM, LPARAM lParam) -{ - SAVEWINDOWPOS *swp = (SAVEWINDOWPOS*)lParam; - WINDOWPLACEMENT wp; - char szSettingName[64]; - - wp.length = sizeof(wp); - GetWindowPlacement(swp->hwnd, &wp); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", swp->szNamePrefix); - db_set_dw(swp->hContact, swp->szModule, szSettingName, wp.rcNormalPosition.left); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", swp->szNamePrefix); - db_set_dw(swp->hContact, swp->szModule, szSettingName, wp.rcNormalPosition.top); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", swp->szNamePrefix); - db_set_dw(swp->hContact, swp->szModule, szSettingName, wp.rcNormalPosition.right-wp.rcNormalPosition.left); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", swp->szNamePrefix); - db_set_dw(swp->hContact, swp->szModule, szSettingName, wp.rcNormalPosition.bottom-wp.rcNormalPosition.top); - return 0; -} - -static INT_PTR svcAssertInsideScreen(WPARAM wParam, LPARAM) -{ - LPRECT rc = (LPRECT)wParam; - if (rc == NULL) - return -1; - - return AssertInsideScreen(*rc); -} - -int AssertInsideScreen(RECT &rc) -{ - RECT rcScreen; - SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, FALSE); - if (MonitorFromRect(&rc, MONITOR_DEFAULTTONULL)) - return 0; - - MONITORINFO mi = {0}; - HMONITOR hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST); - mi.cbSize = sizeof(mi); - if (GetMonitorInfo(hMonitor, &mi)) - rcScreen = mi.rcWork; - - if (rc.top >= rcScreen.bottom) - OffsetRect(&rc, 0, rcScreen.bottom - rc.bottom); - else if (rc.bottom <= rcScreen.top) - OffsetRect(&rc, 0, rcScreen.top - rc.top); - if (rc.left >= rcScreen.right) - OffsetRect(&rc, rcScreen.right - rc.right, 0); - else if (rc.right <= rcScreen.left) - OffsetRect(&rc, rcScreen.left - rc.left, 0); - - return 1; -} - -static INT_PTR RestoreWindowPosition(WPARAM wParam, LPARAM lParam) -{ - SAVEWINDOWPOS *swp = (SAVEWINDOWPOS*)lParam; - WINDOWPLACEMENT wp; - char szSettingName[64]; - int x, y; - - wp.length = sizeof(wp); - GetWindowPlacement(swp->hwnd, &wp); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", swp->szNamePrefix); - x = db_get_dw(swp->hContact, swp->szModule, szSettingName, -1); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", swp->szNamePrefix); - y = (int)db_get_dw(swp->hContact, swp->szModule, szSettingName, -1); - if (x == -1) return 1; - if (wParam&RWPF_NOSIZE) { - OffsetRect(&wp.rcNormalPosition, x-wp.rcNormalPosition.left, y-wp.rcNormalPosition.top); - } - else { - wp.rcNormalPosition.left = x; - wp.rcNormalPosition.top = y; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", swp->szNamePrefix); - wp.rcNormalPosition.right = wp.rcNormalPosition.left+db_get_dw(swp->hContact, swp->szModule, szSettingName, -1); - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", swp->szNamePrefix); - wp.rcNormalPosition.bottom = wp.rcNormalPosition.top+db_get_dw(swp->hContact, swp->szModule, szSettingName, -1); - } - wp.flags = 0; - if (wParam & RWPF_HIDDEN) - wp.showCmd = SW_HIDE; - if (wParam & RWPF_NOACTIVATE) - wp.showCmd = SW_SHOWNOACTIVATE; - - if (!(wParam & RWPF_NOMOVE)) - AssertInsideScreen(wp.rcNormalPosition); - - SetWindowPlacement(swp->hwnd, &wp); - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - static INT_PTR RestartMiranda(WPARAM wParam, LPARAM) { TCHAR mirandaPath[MAX_PATH], cmdLine[MAX_PATH]; @@ -465,9 +372,6 @@ int LoadUtilsModule(void) bModuleInitialized = TRUE; CreateServiceFunction(MS_UTILS_RESIZEDIALOG, ResizeDialog); - CreateServiceFunction(MS_UTILS_SAVEWINDOWPOSITION, SaveWindowPosition); - CreateServiceFunction(MS_UTILS_RESTOREWINDOWPOSITION, RestoreWindowPosition); - CreateServiceFunction(MS_UTILS_ASSERTINSIDESCREEN, svcAssertInsideScreen); CreateServiceFunction(MS_UTILS_GETCOUNTRYBYNUMBER, GetCountryByNumber); CreateServiceFunction(MS_UTILS_GETCOUNTRYBYISOCODE, GetCountryByISOCode); CreateServiceFunction(MS_UTILS_GETCOUNTRYLIST, GetCountryList); -- cgit v1.2.3