summaryrefslogtreecommitdiff
path: root/src/modules/utils/utils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-04-10 21:41:21 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-04-10 21:41:21 +0000
commit2ca49d1d8f694b763fde90fad9a3c9898132f8e9 (patch)
tree6a97c8fb8a9a1a11049c880293dd3147cd93f81c /src/modules/utils/utils.cpp
parent771ccdb89c2ec0733cf16104709ad8670fc34c55 (diff)
more fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@12760 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/utils/utils.cpp')
-rw-r--r--src/modules/utils/utils.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp
index 466d5c04ea..9373759ab5 100644
--- a/src/modules/utils/utils.cpp
+++ b/src/modules/utils/utils.cpp
@@ -346,33 +346,36 @@ static INT_PTR SaveWindowPosition(WPARAM, LPARAM lParam)
return 0;
}
-
-static INT_PTR AssertInsideScreen(WPARAM wParam, LPARAM lParam)
+static INT_PTR svcAssertInsideScreen(WPARAM wParam, LPARAM lParam)
{
- LPRECT rc = (LPRECT) wParam;
+ 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))
+ if (MonitorFromRect(&rc, MONITOR_DEFAULTTONULL))
return 0;
MONITORINFO mi = {0};
- HMONITOR hMonitor = MonitorFromRect(rc, MONITOR_DEFAULTTONEAREST);
+ 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);
+ 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;
}
@@ -409,13 +412,14 @@ static INT_PTR RestoreWindowPosition(WPARAM wParam, LPARAM lParam)
wp.showCmd = SW_SHOWNOACTIVATE;
if (!(wParam & RWPF_NOMOVE))
- AssertInsideScreen((WPARAM) &wp.rcNormalPosition, 0);
+ AssertInsideScreen(wp.rcNormalPosition);
SetWindowPlacement(swp->hwnd, &wp);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
+
static INT_PTR RestartMiranda(WPARAM wParam, LPARAM)
{
TCHAR mirandaPath[MAX_PATH], cmdLine[MAX_PATH];
@@ -465,7 +469,7 @@ int LoadUtilsModule(void)
CreateServiceFunction(MS_UTILS_RESIZEDIALOG, ResizeDialog);
CreateServiceFunction(MS_UTILS_SAVEWINDOWPOSITION, SaveWindowPosition);
CreateServiceFunction(MS_UTILS_RESTOREWINDOWPOSITION, RestoreWindowPosition);
- CreateServiceFunction(MS_UTILS_ASSERTINSIDESCREEN, AssertInsideScreen);
+ CreateServiceFunction(MS_UTILS_ASSERTINSIDESCREEN, svcAssertInsideScreen);
CreateServiceFunction(MS_UTILS_GETCOUNTRYBYNUMBER, GetCountryByNumber);
CreateServiceFunction(MS_UTILS_GETCOUNTRYBYISOCODE, GetCountryByISOCode);
CreateServiceFunction(MS_UTILS_GETCOUNTRYLIST, GetCountryList);