From 125264843b0e1f8afccc85ea30c329f0366eb716 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 25 Sep 2013 13:50:57 +0000 Subject: - custom screen saver detection code removed - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@6230 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Scriver/src/msgwindow.cpp | 541 +++++++++++++++++++------------------- 1 file changed, 266 insertions(+), 275 deletions(-) (limited to 'plugins/Scriver') diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp index abe6b0ac84..89df28fcc6 100644 --- a/plugins/Scriver/src/msgwindow.cpp +++ b/plugins/Scriver/src/msgwindow.cpp @@ -1136,7 +1136,7 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lPar TCITEM tci; LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) lParam; int iTabIndex = lpDIS->itemID; - tcdat = (TabCtrlData *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + tcdat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (iTabIndex >= 0) { HANDLE hTheme = NULL; int tstate; @@ -1247,30 +1247,29 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lPar LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - TabCtrlData *dat; - dat = (TabCtrlData *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + TabCtrlData *dat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + switch(msg) { - case EM_SUBCLASSED: - dat = (TabCtrlData *) mir_alloc(sizeof(TabCtrlData)); - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) dat); - dat->bDragging = FALSE; - dat->bDragged = FALSE; - dat->srcTab = -1; - dat->destTab = -1; - return 0; - case WM_MBUTTONDOWN: + case EM_SUBCLASSED: + dat = (TabCtrlData*)mir_alloc(sizeof(TabCtrlData)); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) dat); + dat->bDragging = FALSE; + dat->bDragged = FALSE; + dat->srcTab = -1; + dat->destTab = -1; + return 0; + + case WM_MBUTTONDOWN: { - TCITEM tci; - int tabId; - MessageWindowTabData *mwtd; TCHITTESTINFO thinfo; thinfo.pt.x = LOWORD(lParam); thinfo.pt.y = HIWORD(lParam); - tabId = TabCtrl_HitTest(hwnd, &thinfo); + int tabId = TabCtrl_HitTest(hwnd, &thinfo); if (tabId >= 0) { + TCITEM tci; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwnd, tabId, &tci); - mwtd = (MessageWindowTabData *) tci.lParam; + MessageWindowTabData *mwtd = (MessageWindowTabData *) tci.lParam; if (mwtd != NULL) { SendMessage(mwtd->hwnd, WM_CLOSE, 0, 0); dat->srcTab = -1; @@ -1278,13 +1277,12 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } return 0; } - case WM_LBUTTONDBLCLK: + case WM_LBUTTONDBLCLK: { TCHITTESTINFO thinfo; - int tabId; thinfo.pt.x = LOWORD(lParam); thinfo.pt.y = HIWORD(lParam); - tabId = TabCtrl_HitTest(hwnd, &thinfo); + int tabId = TabCtrl_HitTest(hwnd, &thinfo); if (tabId >=0 && tabId == dat->srcTab) { SendMessage(GetChildFromTab(hwnd, tabId)->hwnd, WM_CLOSE, 0, 0); dat->srcTab = -1; @@ -1292,284 +1290,277 @@ LRESULT CALLBACK TabCtrlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) dat->destTab = -1; } break; - case WM_LBUTTONDOWN: - if (!dat->bDragging) { - TCHITTESTINFO thinfo; - FILETIME ft; - thinfo.pt.x = LOWORD(lParam); - thinfo.pt.y = HIWORD(lParam); - dat->srcTab = TabCtrl_HitTest(hwnd, &thinfo); - GetSystemTimeAsFileTime(&ft); - if (dat->srcTab >=0 ) { - dat->bDragging = TRUE; - dat->bDragged = FALSE; - dat->clickLParam = lParam; - dat->clickWParam = wParam; - dat->lastClickTime = ft.dwLowDateTime; - dat->mouseLBDownPos.x = thinfo.pt.x; - dat->mouseLBDownPos.y = thinfo.pt.y; - SetCapture(hwnd); + case WM_LBUTTONDOWN: + if (!dat->bDragging) { + TCHITTESTINFO thinfo; + thinfo.pt.x = LOWORD(lParam); + thinfo.pt.y = HIWORD(lParam); + dat->srcTab = TabCtrl_HitTest(hwnd, &thinfo); + + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + if (dat->srcTab >= 0) { + dat->bDragging = TRUE; + dat->bDragged = FALSE; + dat->clickLParam = lParam; + dat->clickWParam = wParam; + dat->lastClickTime = ft.dwLowDateTime; + dat->mouseLBDownPos.x = thinfo.pt.x; + dat->mouseLBDownPos.y = thinfo.pt.y; + SetCapture(hwnd); + } + return 0; + } + break; + case WM_CAPTURECHANGED: + case WM_LBUTTONUP: + if (dat->bDragging) { + TCHITTESTINFO thinfo; + thinfo.pt.x = LOWORD(lParam); + thinfo.pt.y = HIWORD(lParam); + if (dat->bDragged) { + ImageList_DragLeave(GetDesktopWindow()); + ImageList_EndDrag(); + ImageList_Destroy(dat->hDragImageList); + SetCursor(LoadCursor(NULL, IDC_ARROW)); + dat->destTab = TabCtrl_HitTest(hwnd, &thinfo); + if (thinfo.flags != TCHT_NOWHERE && dat->destTab != dat->srcTab) { + NMHDR nmh; + TCHAR sBuffer[501]; + TCITEM item; + int curSel; + curSel = TabCtrl_GetCurSel(hwnd); + item.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT; + item.pszText = sBuffer; + item.cchTextMax = SIZEOF(sBuffer); + TabCtrl_GetItem(hwnd, dat->srcTab, &item); + sBuffer[SIZEOF(sBuffer)-1] = '\0'; + + if (curSel == dat->srcTab) + curSel = dat->destTab; + else if (curSel > dat->srcTab && curSel <= dat->destTab) + curSel--; + else if (curSel < dat->srcTab && curSel >= dat->destTab) + curSel++; + + TabCtrl_DeleteItem(hwnd, dat->srcTab); + TabCtrl_InsertItem(hwnd, dat->destTab, &item ); + TabCtrl_SetCurSel(hwnd, curSel); + dat->destTab = -1; + nmh.hwndFrom = hwnd; + nmh.idFrom = GetDlgCtrlID(hwnd); + nmh.code = TCN_SELCHANGE; + SendMessage(GetParent(hwnd), WM_NOTIFY, nmh.idFrom, (LPARAM)&nmh); + UpdateWindow(hwnd); + } + else if (thinfo.flags == TCHT_NOWHERE) { + TCITEM tci; + POINT pt; + NewMessageWindowLParam newData = { 0 }; + dat->destTab = -1; + tci.mask = TCIF_PARAM; + TabCtrl_GetItem(hwnd, dat->srcTab, &tci); + MessageWindowTabData *mwtd = (MessageWindowTabData *) tci.lParam; + if (mwtd != NULL) { + HWND hChild = mwtd->hwnd; + HANDLE hContact = mwtd->hContact; + GetCursorPos(&pt); + HWND hParent = WindowFromPoint(pt); + while (GetParent(hParent) != NULL) + hParent = GetParent(hParent); + + hParent = WindowList_Find(g_dat.hParentWindowList, 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); + 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; + if (rc.left < rcDesktop.left) + rc.left = rcDesktop.left; + if (rc.top < rcDesktop.top) + rc.top = rcDesktop.top; + MoveWindow(hParent, rc.left, rc.top, rc.right, rc.bottom, FALSE); + } + NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSING); + NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSE); + SetParent(hChild, hParent); + SendMessage(GetParent(hwnd), CM_REMOVECHILD, 0, (LPARAM)hChild); + SendMessage(hChild, DM_SETPARENT, 0, (LPARAM)hParent); + SendMessage(hParent, CM_ADDCHILD, (WPARAM)hChild, (LPARAM)hContact); + SendMessage(hChild, DM_UPDATETABCONTROL, 0, 0); + SendMessage(hParent, CM_ACTIVATECHILD, 0, (LPARAM)hChild); + NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPENING); + NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPEN); + ShowWindow(hParent, SW_SHOWNA); + EnableWindow(hParent, TRUE); + } + } + } + else { + dat->destTab = -1; + RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); } - return 0; } - break; - case WM_CAPTURECHANGED: - case WM_LBUTTONUP: + else if (dat->srcTab >= 0 && g_dat.flags2 & SMF2_TABCLOSEBUTTON) { + IMAGEINFO info; + POINT pt; + RECT rect; + int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0; + TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect); + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info); + rect.left = rect.right - (info.rcImage.right - info.rcImage.left) - 6; + if (!atTop) + rect.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top); + + if (pt.x >= rect.left && pt.x < rect.left + (info.rcImage.right - info.rcImage.left) && pt.y >= rect.top && pt.y < rect.top + (info.rcImage.bottom - info.rcImage.top)) { + HBITMAP hOldBitmap, hBmp; + HDC hdc = GetDC(NULL); + HDC hdcMem = CreateCompatibleDC(hdc); + pt.x -= rect.left; + pt.y -= rect.top; + hBmp = CreateCompatibleBitmap(hdc, info.rcImage.right - info.rcImage.left + 1, info.rcImage.bottom - info.rcImage.top + 1); + hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmp); + SetPixel(hdcMem, pt.x, pt.y, 0x000000); + ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL); + COLORREF color1 = GetPixel(hdcMem, pt.x, pt.y); + SetPixel(hdcMem, pt.x, pt.y, 0xFFFFFF); + ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL); + COLORREF color2 = GetPixel(hdcMem, pt.x, pt.y); + SelectObject(hdcMem, hOldBitmap); + DeleteDC(hdcMem); + DeleteObject(hBmp); + ReleaseDC(NULL, hdc); + if (color1 != 0x000000 || color2 != 0xFFFFFF) { + SendMessage(GetChildFromTab(hwnd, dat->srcTab)->hwnd, WM_CLOSE, 0, 0); + dat->srcTab = -1; + } + } + else SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam); + } + else SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam); + + dat->bDragged = FALSE; + dat->bDragging = FALSE; + dat->destTab = -1; + ReleaseCapture(); + } + break; + case WM_MOUSEMOVE: + if (wParam & MK_LBUTTON) { if (dat->bDragging) { + FILETIME ft; TCHITTESTINFO thinfo; + GetSystemTimeAsFileTime(&ft); thinfo.pt.x = LOWORD(lParam); thinfo.pt.y = HIWORD(lParam); - if (dat->bDragged) { - ImageList_DragLeave(GetDesktopWindow()); - ImageList_EndDrag(); - ImageList_Destroy(dat->hDragImageList); - SetCursor(LoadCursor(NULL, IDC_ARROW)); - dat->destTab = TabCtrl_HitTest(hwnd, &thinfo); - if (thinfo.flags != TCHT_NOWHERE && dat->destTab != dat->srcTab) { - NMHDR nmh; - TCHAR sBuffer[501]; - TCITEM item; - int curSel; - curSel = TabCtrl_GetCurSel(hwnd); - item.mask = TCIF_IMAGE | TCIF_PARAM | TCIF_TEXT; - item.pszText = sBuffer; - item.cchTextMax = SIZEOF(sBuffer); - TabCtrl_GetItem(hwnd, dat->srcTab, &item); - sBuffer[SIZEOF(sBuffer)-1] = '\0'; - if (curSel == dat->srcTab) { - curSel = dat->destTab; - } else { - if (curSel > dat->srcTab && curSel <= dat->destTab) { - curSel--; - } else if (curSel < dat->srcTab && curSel >= dat->destTab) { - curSel++; - } - } - TabCtrl_DeleteItem(hwnd, dat->srcTab); - TabCtrl_InsertItem(hwnd, dat->destTab, &item ); - TabCtrl_SetCurSel(hwnd, curSel); - dat->destTab = -1; - nmh.hwndFrom = hwnd; - nmh.idFrom = GetDlgCtrlID(hwnd); - nmh.code = TCN_SELCHANGE; - SendMessage(GetParent(hwnd), WM_NOTIFY, nmh.idFrom, (LPARAM)&nmh); - UpdateWindow(hwnd); - } else if (thinfo.flags == TCHT_NOWHERE) { - MessageWindowTabData *mwtd; - TCITEM tci; - POINT pt; - NewMessageWindowLParam newData = { 0 }; - dat->destTab = -1; - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(hwnd, dat->srcTab, &tci); - mwtd = (MessageWindowTabData *) tci.lParam; - if (mwtd != NULL) { - HWND hChild = mwtd->hwnd; - HANDLE hContact = mwtd->hContact; - HWND hParent; - GetCursorPos(&pt); - hParent = WindowFromPoint(pt); - while (GetParent(hParent) != NULL) { - hParent = GetParent(hParent); - } - hParent = WindowList_Find(g_dat.hParentWindowList, hParent); - if ((hParent != NULL && hParent != GetParent(hwnd)) || (hParent == NULL && mwtd->parent->childrenCount > 1 && (GetKeyState(VK_CONTROL) & 0x8000))) { - if (hParent == NULL) { - MONITORINFO mi; - HMONITOR hMonitor; - RECT rc, rcDesktop; - newData.hContact = hContact; - hParent = (HWND)CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM)& newData); - 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 = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST); - mi.cbSize = sizeof(mi); - GetMonitorInfo(hMonitor, &mi); - rcDesktop = mi.rcWork; - if (rc.left < rcDesktop.left) { - rc.left = rcDesktop.left; - } - if (rc.top < rcDesktop.top) { - rc.top = rcDesktop.top; - } - MoveWindow(hParent, rc.left, rc.top, rc.right, rc.bottom, FALSE); - - } - NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSING); - NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_CLOSE); - SetParent(hChild, hParent); - SendMessage(GetParent(hwnd), CM_REMOVECHILD, 0, (LPARAM)hChild); - SendMessage(hChild, DM_SETPARENT, 0, (LPARAM)hParent); - SendMessage(hParent, CM_ADDCHILD, (WPARAM)hChild, (LPARAM)hContact); - SendMessage(hChild, DM_UPDATETABCONTROL, 0, 0); - SendMessage(hParent, CM_ACTIVATECHILD, 0, (LPARAM)hChild); - NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPENING); - NotifyLocalWinEvent(hContact, hChild, MSG_WINDOW_EVT_OPEN); - ShowWindow(hParent, SW_SHOWNA); - EnableWindow(hParent, TRUE); - } - } - } else { - dat->destTab = -1; - RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); - } - } else if (dat->srcTab >= 0 && g_dat.flags2 & SMF2_TABCLOSEBUTTON) { - IMAGEINFO info; + if (!dat->bDragged) { + if ((abs(thinfo.pt.x-dat->mouseLBDownPos.x)<3 && abs(thinfo.pt.y-dat->mouseLBDownPos.y)<3) + || (ft.dwLowDateTime - dat->lastClickTime) < 10*1000*150) + break; + } + if (!dat->bDragged) { POINT pt; RECT rect; - int atTop = (GetWindowLongPtr(hwnd, GWL_STYLE) & TCS_BOTTOM) == 0; + RECT rect2; + HBRUSH hBrush = CreateSolidBrush(RGB(255,0,254)); + GetCursorPos(&pt); TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect); - pt.x = LOWORD(lParam); - pt.y = HIWORD(lParam); - ImageList_GetImageInfo(g_dat.hButtonIconList, 0, &info); - rect.left = rect.right - (info.rcImage.right - info.rcImage.left) - 6; - if (!atTop) { - rect.top = rect.bottom - (info.rcImage.bottom - info.rcImage.top); - } - if (pt.x >= rect.left && pt.x < rect.left + (info.rcImage.right - info.rcImage.left) && pt.y >= rect.top && pt.y < rect.top + (info.rcImage.bottom - info.rcImage.top)) { - HBITMAP hOldBitmap, hBmp; - COLORREF color1, color2; - HDC hdc = GetDC(NULL); - HDC hdcMem = CreateCompatibleDC(hdc); - pt.x -= rect.left; - pt.y -= rect.top; - hBmp = CreateCompatibleBitmap(hdc, info.rcImage.right - info.rcImage.left + 1, info.rcImage.bottom - info.rcImage.top + 1); - hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmp); - SetPixel(hdcMem, pt.x, pt.y, 0x000000); - ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL); - color1 = GetPixel(hdcMem, pt.x, pt.y); - SetPixel(hdcMem, pt.x, pt.y, 0xFFFFFF); - ImageList_DrawEx(g_dat.hButtonIconList, 0, hdcMem, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL); - color2 = GetPixel(hdcMem, pt.x, pt.y); - SelectObject(hdcMem, hOldBitmap); - DeleteDC(hdcMem); - DeleteObject(hBmp); - ReleaseDC(NULL, hdc); - if (color1 != 0x000000 || color2 != 0xFFFFFF) { - SendMessage(GetChildFromTab(hwnd, dat->srcTab)->hwnd, WM_CLOSE, 0, 0); - dat->srcTab = -1; - } - } else { - SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam); - } - } else { - SendMessage(hwnd, WM_LBUTTONDOWN, dat->clickWParam, dat->clickLParam); + rect.right -= rect.left-1; + rect.bottom -= rect.top-1; + rect2.left = 0; rect2.right = rect.right; rect2.top = 0; rect2.bottom = rect.bottom; + dat->hDragImageList = ImageList_Create(rect.right, rect.bottom, ILC_COLOR | ILC_MASK, 0, 1); + HDC hDC = GetDC(hwnd); + HDC hMemDC = CreateCompatibleDC(hDC); + HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rect.right, rect.bottom); + HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap); + FillRect(hMemDC, &rect2, hBrush); + SetWindowOrgEx (hMemDC, rect.left, rect.top, NULL); + SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hMemDC, PRF_CLIENT); + SelectObject(hMemDC, hOldBitmap); + ImageList_AddMasked(dat->hDragImageList, hBitmap, RGB(255,0,254)); + DeleteObject(hBitmap); + DeleteObject(hBrush); + ReleaseDC(hwnd, hDC); + DeleteDC(hMemDC); + ImageList_BeginDrag(dat->hDragImageList, 0, dat->mouseLBDownPos.x - rect.left, dat->mouseLBDownPos.y - rect.top); + ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y); + SetCursor(hDragCursor); + dat->mouseLBDownPos.x = thinfo.pt.x; + dat->mouseLBDownPos.y = thinfo.pt.y; } - dat->bDragged = FALSE; - dat->bDragging = FALSE; - dat->destTab = -1; - ReleaseCapture(); - } - break; - case WM_MOUSEMOVE: - if (wParam & MK_LBUTTON) { - if (dat->bDragging) { - FILETIME ft; + else { TCHITTESTINFO thinfo; - GetSystemTimeAsFileTime(&ft); - thinfo.pt.x = LOWORD(lParam); - thinfo.pt.y = HIWORD(lParam); - if (!dat->bDragged) { - if ((abs(thinfo.pt.x-dat->mouseLBDownPos.x)<3 && abs(thinfo.pt.y-dat->mouseLBDownPos.y)<3) - || (ft.dwLowDateTime - dat->lastClickTime) < 10*1000*150) - break; - } - if (!dat->bDragged) { - POINT pt; - RECT rect; - RECT rect2; - HDC hDC, hMemDC; - HBITMAP hBitmap, hOldBitmap; - HBRUSH hBrush = CreateSolidBrush(RGB(255,0,254)); - GetCursorPos(&pt); - TabCtrl_GetItemRect(hwnd, dat->srcTab, &rect); - rect.right -= rect.left-1; - rect.bottom -= rect.top-1; - rect2.left = 0; rect2.right = rect.right; rect2.top = 0; rect2.bottom = rect.bottom; - dat->hDragImageList = ImageList_Create(rect.right, rect.bottom, ILC_COLOR | ILC_MASK, 0, 1); - hDC = GetDC(hwnd); - hMemDC = CreateCompatibleDC(hDC); - hBitmap = CreateCompatibleBitmap(hDC, rect.right, rect.bottom); - hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap); - FillRect(hMemDC, &rect2, hBrush); - SetWindowOrgEx (hMemDC, rect.left, rect.top, NULL); - SendMessage(hwnd, WM_PRINTCLIENT, (WPARAM)hMemDC, PRF_CLIENT); - SelectObject(hMemDC, hOldBitmap); - ImageList_AddMasked(dat->hDragImageList, hBitmap, RGB(255,0,254)); - DeleteObject(hBitmap); - DeleteObject(hBrush); - ReleaseDC(hwnd, hDC); - DeleteDC(hMemDC); - ImageList_BeginDrag(dat->hDragImageList, 0, dat->mouseLBDownPos.x - rect.left, dat->mouseLBDownPos.y - rect.top); + POINT pt; + GetCursorPos(&pt); + thinfo.pt = pt; + ScreenToClient(hwnd, &thinfo.pt); + int newDest = TabCtrl_HitTest(hwnd, &thinfo); + if (thinfo.flags == TCHT_NOWHERE) + newDest = -1; + + if (newDest != dat->destTab) { + dat->destTab = newDest; + ImageList_DragLeave(GetDesktopWindow()); + RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW); ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y); - SetCursor(hDragCursor); - dat->mouseLBDownPos.x = thinfo.pt.x; - dat->mouseLBDownPos.y = thinfo.pt.y; - } else { - TCHITTESTINFO thinfo; - POINT pt; - int newDest; - GetCursorPos(&pt); - thinfo.pt = pt; - ScreenToClient(hwnd, &thinfo.pt); - newDest = TabCtrl_HitTest(hwnd, &thinfo); - if (thinfo.flags == TCHT_NOWHERE) { - newDest = -1; - } - if (newDest != dat->destTab) { - dat->destTab = newDest; - ImageList_DragLeave(GetDesktopWindow()); - RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW); - ImageList_DragEnter(GetDesktopWindow(), pt.x, pt.y); - } else { - ImageList_DragMove(pt.x, pt.y); - } } - dat->bDragged = TRUE; - return 0; + else ImageList_DragMove(pt.x, pt.y); } + dat->bDragged = TRUE; + return 0; } - break; - case EM_UNSUBCLASSED: - mir_free(dat); - return 0; + } + break; + + case EM_UNSUBCLASSED: + mir_free(dat); + return 0; } return mir_callNextSubclass(hwnd, TabCtrlProc, msg, wParam, lParam); } -int ScriverRestoreWindowPosition(HWND hwnd,HANDLE hContact,const char *szModule,const char *szNamePrefix, int flags, int showCmd) +int ScriverRestoreWindowPosition(HWND hwnd, HANDLE hContact, const char *szModule,const char *szNamePrefix, int flags, int showCmd) { RECT rcDesktop; WINDOWPLACEMENT wp; + wp.length = sizeof(wp); + GetWindowPlacement(hwnd, &wp); + char szSettingName[64]; - int x,y; - MONITORINFO mi; - HMONITOR hMonitor; -// SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDesktop, 0); - wp.length=sizeof(wp); - GetWindowPlacement(hwnd,&wp); mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", szNamePrefix); - x=db_get_dw(hContact,szModule,szSettingName,-1); + int x = db_get_dw(hContact,szModule,szSettingName,-1); mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", szNamePrefix); - y=(int)db_get_dw(hContact,szModule,szSettingName,-1); - if (x==-1) return 1; - if (flags&RWPF_NOSIZE) { + 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; + 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); + 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.rcNormalPosition.bottom = wp.rcNormalPosition.top + db_get_dw(hContact,szModule,szSettingName,-1); } - wp.flags=0; + wp.flags = 0; wp.showCmd = showCmd; - hMonitor = MonitorFromRect(&wp.rcNormalPosition, MONITOR_DEFAULTTONEAREST); + HMONITOR hMonitor = MonitorFromRect(&wp.rcNormalPosition, MONITOR_DEFAULTTONEAREST); + MONITORINFO mi; mi.cbSize = sizeof(mi); GetMonitorInfo(hMonitor, &mi); rcDesktop = mi.rcWork; @@ -1586,22 +1577,22 @@ HWND GetParentWindow(HANDLE hContact, BOOL bChat) { if (g_dat.flags2 & SMF2_USETABS) { if (!bChat || !(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS)) { if (g_dat.lastParent != NULL) { - int tabsNum = (int) SendMessage(g_dat.lastParent->hwnd, CM_GETCHILDCOUNT, 0, 0); - if (!(g_dat.flags2 & SMF2_LIMITTABS) || tabsNum < g_dat.limitTabsNum) { + int tabsNum = (int)SendMessage(g_dat.lastParent->hwnd, CM_GETCHILDCOUNT, 0, 0); + if (!(g_dat.flags2 & SMF2_LIMITTABS) || tabsNum < g_dat.limitTabsNum) return g_dat.lastParent->hwnd; - } } - } else { + } + else { if (g_dat.lastChatParent != NULL) { - int tabsNum = (int) SendMessage(g_dat.lastChatParent->hwnd, CM_GETCHILDCOUNT, 0, 0); + int tabsNum = (int)SendMessage(g_dat.lastChatParent->hwnd, CM_GETCHILDCOUNT, 0, 0); if (!(g_dat.flags2 & SMF2_LIMITCHATSTABS) || tabsNum < g_dat.limitChatsTabsNum) { return g_dat.lastChatParent->hwnd; } } } } - if (!(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS)) { - newData.isChat =FALSE; - } + if ( !(g_dat.flags2 & SMF2_SEPARATECHATSCONTAINERS)) + newData.isChat = FALSE; + return CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM)& newData); } -- cgit v1.2.3