diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-17 17:03:45 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-17 17:03:45 +0000 |
commit | a75ce08f5ea46237b73e5052a956829c0e272678 (patch) | |
tree | 60a238c3b4c0487317f3836d83acbe022c865115 /src | |
parent | d6964f7bb1c2afc8d67905fa38ac9a3df766b807 (diff) |
minus MS_UTILS_SAVEWINDOWPOSITION & MS_UTILS_RESTOREWINDOWPOSITION
git-svn-id: http://svn.miranda-ng.org/main/trunk@14238 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdfile/src/ftmanager.cpp | 6 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/clistmod.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/clui.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/utils.cpp | 96 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 3 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 3 | ||||
-rw-r--r-- | src/mir_core/src/winutil.cpp | 118 |
9 files changed, 130 insertions, 107 deletions
diff --git a/src/core/stdfile/src/ftmanager.cpp b/src/core/stdfile/src/ftmanager.cpp index 139ffbffbd..35af052eb7 100644 --- a/src/core/stdfile/src/ftmanager.cpp +++ b/src/core/stdfile/src/ftmanager.cpp @@ -288,11 +288,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM tci.lParam = (LPARAM)dat->hwndOutgoing;
TabCtrl_InsertItem(hwndTab, 1, &tci);
- // Utils_RestoreWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_");
- SAVEWINDOWPOS swp;
- swp.hwnd = hwnd; swp.hContact = NULL; swp.szModule = "SRFile"; swp.szNamePrefix = "FtMgrDlg_";
- CallService(MS_UTILS_RESTOREWINDOWPOSITION, RWPF_NOACTIVATE, (LPARAM)&swp);
-
+ Utils_RestoreWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_", RWPF_NOACTIVATE);
// Fall through to setup initial placement
}
case WM_SIZE:
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 775a202f20..b3a9bc050a 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -779,9 +779,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP {
int flag = newData->noActivate ? RWPF_HIDDEN : 0;
int savePerContact = db_get_b(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT);
- if (Utils_RestoreWindowPositionEx(hwndDlg, flag, savePerContact ? dat->hContact : NULL, SRMMMOD, "")) {
+ if (Utils_RestoreWindowPosition(hwndDlg, savePerContact ? dat->hContact : NULL, SRMMMOD, "", flag)) {
if (savePerContact) {
- if (Utils_RestoreWindowPositionEx(hwndDlg, flag | RWPF_NOMOVE, NULL, SRMMMOD, ""))
+ if (Utils_RestoreWindowPosition(hwndDlg, NULL, SRMMMOD, "", flag | RWPF_NOMOVE))
SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);
}
else SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);
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);
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 030e9378df..026c144ae2 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1053,3 +1053,6 @@ WindowList_Destroy @1106 WindowList_Find @1107
WindowList_Remove @1108
?SetSilent@CCtrlBase@@QAEXXZ @1109 NONAME
+Utils_AssertInsideScreen @1110
+Utils_RestoreWindowPosition @1111
+Utils_SaveWindowPosition @1112
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index b2139750cf..d777fb539f 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1053,3 +1053,6 @@ WindowList_Destroy @1106 WindowList_Find @1107
WindowList_Remove @1108
?SetSilent@CCtrlBase@@QEAAXXZ @1109 NONAME
+Utils_AssertInsideScreen @1110
+Utils_RestoreWindowPosition @1111
+Utils_SaveWindowPosition @1112
diff --git a/src/mir_core/src/winutil.cpp b/src/mir_core/src/winutil.cpp new file mode 100644 index 0000000000..0dd0a2e897 --- /dev/null +++ b/src/mir_core/src/winutil.cpp @@ -0,0 +1,118 @@ +/*
+
+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"
+
+MIR_CORE_DLL(int) Utils_SaveWindowPosition(HWND hwnd, MCONTACT hContact, const char *szModule, const char *szNamePrefix)
+{
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(hwnd, &wp);
+
+ char szSettingName[64];
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", szNamePrefix);
+ db_set_dw(hContact, szModule, szSettingName, wp.rcNormalPosition.left);
+
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", szNamePrefix);
+ db_set_dw(hContact, szModule, szSettingName, wp.rcNormalPosition.top);
+
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", szNamePrefix);
+ db_set_dw(hContact, szModule, szSettingName, wp.rcNormalPosition.right-wp.rcNormalPosition.left);
+
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", szNamePrefix);
+ db_set_dw(hContact, szModule, szSettingName, wp.rcNormalPosition.bottom-wp.rcNormalPosition.top);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+EXTERN_C MIR_CORE_DLL(int) Utils_RestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szModule, const char *szNamePrefix, int flags)
+{
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(hwnd, &wp);
+
+ char szSettingName[64];
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", szNamePrefix);
+ int x = db_get_dw(hContact, szModule, szSettingName, -1);
+ if (x == -1)
+ return 1;
+
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", szNamePrefix);
+ int y = (int)db_get_dw(hContact, szModule, szSettingName, -1);
+
+ if (flags & 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", szNamePrefix);
+ wp.rcNormalPosition.right = wp.rcNormalPosition.left+db_get_dw(hContact, szModule, szSettingName, -1);
+
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", szNamePrefix);
+ wp.rcNormalPosition.bottom = wp.rcNormalPosition.top+db_get_dw(hContact, szModule, szSettingName, -1);
+ }
+ wp.flags = 0;
+ if (flags & RWPF_HIDDEN)
+ wp.showCmd = SW_HIDE;
+ if (flags & RWPF_NOACTIVATE)
+ wp.showCmd = SW_SHOWNOACTIVATE;
+
+ if (!(flags & RWPF_NOMOVE))
+ Utils_AssertInsideScreen(&wp.rcNormalPosition);
+
+ SetWindowPlacement(hwnd, &wp);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_CORE_DLL(int) Utils_AssertInsideScreen(RECT *rc)
+{
+ if (rc == NULL)
+ return -1;
+
+ 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;
+}
|