summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-12-23 20:18:42 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-12-23 20:18:42 +0300
commit9c8409da79196441817709b590cc5152936afc56 (patch)
tree8d7eb91bb5a6c68a1a2e387658f27cf2db84c8c5 /plugins/Scriver/src
parent64b2f3a0823db9bbfc428e3872e751f15cb07201 (diff)
minor code cleaning
Diffstat (limited to 'plugins/Scriver/src')
-rw-r--r--plugins/Scriver/src/globals.h1
-rw-r--r--plugins/Scriver/src/msgs.h1
-rw-r--r--plugins/Scriver/src/msgwindow.cpp99
3 files changed, 51 insertions, 50 deletions
diff --git a/plugins/Scriver/src/globals.h b/plugins/Scriver/src/globals.h
index bf78d0b259..a396493a4a 100644
--- a/plugins/Scriver/src/globals.h
+++ b/plugins/Scriver/src/globals.h
@@ -126,7 +126,6 @@ void ReleaseIcons();
void LoadGlobalIcons();
HICON GetCachedIcon(const char *name);
void RegisterFontServiceFonts();
-int ScriverRestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szModule, const char *szNamePrefix, int flags, int showCmd);
int ImageList_AddIcon_Ex(HIMAGELIST hIml, int id);
int ImageList_AddIcon_Ex2(HIMAGELIST hIml, HICON hIcon);
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h
index a4e6d42553..2a2ba4411c 100644
--- a/plugins/Scriver/src/msgs.h
+++ b/plugins/Scriver/src/msgs.h
@@ -215,7 +215,6 @@ struct CREOleCallback2 : public CREOleCallback
STDMETHOD(QueryAcceptData) (LPDATAOBJECT lpdataobj, CLIPFORMAT FAR *lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict);
};
-INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
int DbEventIsShown(DBEVENTINFO &dbei);
diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp
index eea70544f1..9c18edc424 100644
--- a/plugins/Scriver/src/msgwindow.cpp
+++ b/plugins/Scriver/src/msgwindow.cpp
@@ -489,16 +489,17 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
UpdateWindow(hwnd);
}
else if (thinfo.flags == TCHT_NOWHERE) {
- TCITEM tci;
- POINT pt;
- NewMessageWindowLParam newData = { 0 };
dat->destTab = -1;
+
+ TCITEM tci;
tci.mask = TCIF_PARAM;
TabCtrl_GetItem(hwnd, dat->srcTab, &tci);
MessageWindowTabData *mwtd = (MessageWindowTabData *)tci.lParam;
if (mwtd != NULL) {
HWND hChild = mwtd->hwnd;
MCONTACT hContact = mwtd->hContact;
+
+ POINT pt;
GetCursorPos(&pt);
HWND hParent = WindowFromPoint(pt);
while (GetParent(hParent) != NULL)
@@ -507,19 +508,22 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
hParent = WindowList_Find(g_dat.hParentWindowList, (UINT_PTR)hParent);
if ((hParent != NULL && hParent != GetParent(hwnd)) || (hParent == NULL && mwtd->parent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) {
if (hParent == NULL) {
- RECT rc, rcDesktop;
- newData.hContact = hContact;
- hParent = (HWND)CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM)&newData);
+ hParent = GetParentWindow(hContact, FALSE);
+
+ RECT rc;
GetWindowRect(hParent, &rc);
+
rc.right = (rc.right - rc.left);
rc.bottom = (rc.bottom - rc.top);
rc.left = pt.x - rc.right / 2;
rc.top = pt.y - rc.bottom / 2;
HMONITOR hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST);
+
MONITORINFO mi;
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);
- rcDesktop = mi.rcWork;
+
+ RECT rcDesktop = mi.rcWork;
if (rc.left < rcDesktop.left)
rc.left = rcDesktop.left;
if (rc.top < rcDesktop.top)
@@ -586,8 +590,7 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
else SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam);
- dat->bDragged = FALSE;
- dat->bDragging = FALSE;
+ dat->bDragged = dat->bDragging = FALSE;
dat->destTab = -1;
ReleaseCapture();
}
@@ -678,7 +681,45 @@ __forceinline void UnsubclassTabCtrl(HWND hwnd)
/////////////////////////////////////////////////////////////////////////////////////////
-INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static int ScriverRestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szModule, const char *szNamePrefix, int flags, int showCmd)
+{
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(hwnd, &wp);
+
+ char szSettingName[64];
+ mir_snprintf(szSettingName, "%sx", szNamePrefix);
+ int x = db_get_dw(hContact, szModule, szSettingName, -1);
+ mir_snprintf(szSettingName, "%sy", szNamePrefix);
+ int y = db_get_dw(hContact, szModule, szSettingName, -1);
+ if (x == -1)
+ return 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, "%swidth", szNamePrefix);
+ wp.rcNormalPosition.right = wp.rcNormalPosition.left + db_get_dw(hContact, szModule, szSettingName, -1);
+ mir_snprintf(szSettingName, "%sheight", szNamePrefix);
+ wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + db_get_dw(hContact, szModule, szSettingName, -1);
+ }
+ wp.flags = 0;
+ wp.showCmd = showCmd;
+
+ HMONITOR hMonitor = MonitorFromRect(&wp.rcNormalPosition, MONITOR_DEFAULTTONEAREST);
+ MONITORINFO mi;
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfo(hMonitor, &mi);
+ RECT rcDesktop = mi.rcWork;
+ if (wp.rcNormalPosition.left > rcDesktop.right || wp.rcNormalPosition.top > rcDesktop.bottom ||
+ wp.rcNormalPosition.right < rcDesktop.left || wp.rcNormalPosition.bottom < rcDesktop.top) return 1;
+ SetWindowPlacement(hwnd, &wp);
+ return 0;
+}
+
+static INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
ParentWindowData *dat = (ParentWindowData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (!dat && msg != WM_INITDIALOG)
@@ -1450,44 +1491,6 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM, LPARAM lParam)
}
}
-int ScriverRestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szModule, const char *szNamePrefix, int flags, int showCmd)
-{
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(hwnd, &wp);
-
- char szSettingName[64];
- mir_snprintf(szSettingName, "%sx", szNamePrefix);
- int x = db_get_dw(hContact, szModule, szSettingName, -1);
- mir_snprintf(szSettingName, "%sy", szNamePrefix);
- int y = db_get_dw(hContact, szModule, szSettingName, -1);
- if (x == -1)
- return 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, "%swidth", szNamePrefix);
- wp.rcNormalPosition.right = wp.rcNormalPosition.left + db_get_dw(hContact, szModule, szSettingName, -1);
- mir_snprintf(szSettingName, "%sheight", szNamePrefix);
- wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + db_get_dw(hContact, szModule, szSettingName, -1);
- }
- wp.flags = 0;
- wp.showCmd = showCmd;
-
- HMONITOR hMonitor = MonitorFromRect(&wp.rcNormalPosition, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi;
- mi.cbSize = sizeof(mi);
- GetMonitorInfo(hMonitor, &mi);
- RECT rcDesktop = mi.rcWork;
- if (wp.rcNormalPosition.left > rcDesktop.right || wp.rcNormalPosition.top > rcDesktop.bottom ||
- wp.rcNormalPosition.right < rcDesktop.left || wp.rcNormalPosition.bottom < rcDesktop.top) return 1;
- SetWindowPlacement(hwnd, &wp);
- return 0;
-}
-
HWND GetParentWindow(MCONTACT hContact, BOOL bChat)
{
NewMessageWindowLParam newData = { 0 };