void ChooseWindowPushButton::refreshWindow(const WindowHandle &handle) { InvalidateRect(handle.value(), NULL, TRUE); UpdateWindow(handle.value()); RedrawWindow(handle.value(), NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_ERASENOW | RDW_UPDATENOW | RDW_ALLCHILDREN); HWND hParent = GetParent(handle.value()); if(hParent) { RECT rc; GetWindowRect(handle.value(), &rc); POINT ptTopLeft = RectTopLeft(rc); POINT ptBottomRight = RectBottomRight(rc); ScreenToClient(hParent, &ptTopLeft); ScreenToClient(hParent, &ptBottomRight); rc.top = ptTopLeft.y; rc.left = ptTopLeft.x; rc.bottom = ptBottomRight.y; rc.right = ptBottomRight.x; InvalidateRect(hParent, &rc, TRUE); UpdateWindow(hParent); RedrawWindow(hParent, &rc, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); } }
void Splitter::LButtonDown(POINTS pt) { dragStarted = true; WindowHandle parent = GetParent(); CaptureMouse(); // Find x offset of splitter // with respect to parent client area POINT ptOrg = {0, 0 }; parent.ClientToScreen(ptOrg); int xParent = ptOrg.x; ptOrg.x = 0; ClientToScreen(ptOrg); int xChild = ptOrg.x; dragStart = xChild - xParent + width / 2 - pt.x; dragX = dragStart + pt.x; // Draw a divider using XOR mode UpdateCanvas canvas(parent); ModeSetter mode(canvas, R2_NOTXORPEN); canvas.Line(dragX, 0, dragX, height - 1); }
void Splitter::LButtonUp(POINTS pt) { if (dragStarted) { WindowHandle parent = GetParent(); dragStarted = false; ::ReleaseCapture(); parent.SendMsg(MSG_MOVESPLITTER, dragStart + pt.x); } }
QPixmap ScreenShooter::captureWindow(WindowHandle window) { if(!window.isValid()) return QPixmap(); const QRect &windowGeometry = window.rect(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) return QGuiApplication::primaryScreen()->grabWindow(0, windowGeometry.x(), windowGeometry.y(), windowGeometry.width(), windowGeometry.height()); #else QDesktopWidget *desktop = QApplication::desktop(); return QPixmap::grabWindow(desktop->winId(), windowGeometry.x(), windowGeometry.y(), windowGeometry.width(), windowGeometry.height()); #endif }
bool ChooseWindowPushButton::isWindowValid(const WindowHandle &handle) const { if(!handle.isValid()) return false; if(handle == mLastFoundWindow) return false; #ifdef Q_WS_WIN if(!IsWindow(handle.value())) return false; #endif foreach(QWidget *widget, mWindowIgnoreList) { if(widget->winId() == handle.value()) return false; } return true; }
void ChooseWindowPushButton::highlightWindow(const WindowHandle &handle) { HDC hWindowDC = NULL; // The DC of the found window. HGDIOBJ hPrevPen = NULL; // Handle of the existing pen in the DC of the found window. HGDIOBJ hPrevBrush = NULL; // Handle of the existing brush in the DC of the found window. RECT rect; // Rectangle area of the found window. GetWindowRect(handle.value(), &rect); hWindowDC = GetWindowDC(handle.value()); if(hWindowDC) { hPrevPen = SelectObject(hWindowDC, mRectanglePen); hPrevBrush = SelectObject(hWindowDC, GetStockObject(HOLLOW_BRUSH)); // Draw a rectangle in the DC covering the entire window area of the found window. Rectangle(hWindowDC, 0, 0, rect.right - rect.left, rect.bottom - rect.top); SelectObject(hWindowDC, hPrevPen); SelectObject(hWindowDC, hPrevBrush); ReleaseDC(handle.value(), hWindowDC); } }
void WindowEdit::on_choose_searchEnded(const WindowHandle &handle) { ui->window->codeLineEdit()->setText(handle.title()); }