// This is a special version of GetClientRect for Aero Glass // to give us the portion of the window that is not our custom // non-client glass so we can: // 1) Exclude it from drawing the background and other stuffs // 2) Position the browser window in derived classes BOOL cef_dark_aero_window::GetRealClientRect(LPRECT rect) const { GetClientRect(rect); RECT rectMenu; ComputeRequiredMenuRect(rectMenu); RECT rectCaption; ComputeWindowCaptionRect(rectCaption); rect->top = rectCaption.bottom + ::RectHeight(rectMenu) + 4; rect->bottom -= ::kWindowFrameSize; rect->left += ::kWindowFrameSize; rect->right -= ::kWindowFrameSize; if (CanUseAeroGlass() && IsZoomed()) { // adjust for auto-hide task bar WORD edges = WindowsTaskBar::GetAutoHideEdges(mWnd); if (edges & WindowsTaskBar::BOTTOM_EDGE) { rect->bottom += ::kWindowFrameSize; } if (edges & WindowsTaskBar::RIGHT_EDGE) { rect->right += ::kWindowFrameSize; } if (edges & WindowsTaskBar::LEFT_EDGE) { rect->left -= ::kWindowFrameSize; } } return TRUE; }
void cef_dark_aero_window::DrawMenuBar(HDC hdc) { RECT rectWindow ; ComputeLogicalWindowRect (rectWindow) ; ::ExcludeClipRect (hdc, rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom); RECT rectRequired; ComputeRequiredMenuRect(rectRequired); // No menu == nothing to draw if (::RectHeight(rectRequired) > 0) { RECT rectMenu; ComputeMenuBarRect(rectMenu); HRGN hrgnUpdate = ::CreateRectRgnIndirect(&rectMenu); if (::SelectClipRgn(hdc, hrgnUpdate) != NULLREGION) { DoDrawFrame(hdc); // Draw menu bar background DoDrawMenuBar(hdc); // DraW menu items } ::DeleteObject(hrgnUpdate); } }
// This is a special version of GetClientRect for Aero Glass // to give us the portion of the window that is not our custom // non-client glass so we can: // 1) Exclude it from drawing the background and other stuffs // 2) Position the browser window in derived classes BOOL cef_dark_aero_window::GetRealClientRect(LPRECT rect) const { GetClientRect(rect); RECT rectMenu; ComputeRequiredMenuRect(rectMenu); RECT rectCaption; ComputeWindowCaptionRect(rectCaption); rect->top = rectCaption.bottom + ::RectHeight(rectMenu) + 4; rect->bottom -= ::kWindowFrameSize; rect->left += ::kWindowFrameSize; rect->right -= ::kWindowFrameSize; return TRUE; }
// WM_NCHITTEST handler int cef_dark_aero_window::HandleNcHitTest(LPPOINT ptHit) { RECT rectWindow; GetWindowRect(&rectWindow); if (!::PtInRect(&rectWindow, *ptHit)) return HTNOWHERE; RECT rectCaption; ComputeWindowCaptionRect(rectCaption); ClientToScreen(&rectCaption); if (::PtInRect(&rectCaption, *ptHit)) return HTCAPTION; RECT rectCloseButton; ComputeCloseButtonRect(rectCloseButton); ClientToScreen(&rectCloseButton); if (::PtInRect(&rectCloseButton, *ptHit)) return HTCLOSE; RECT rectMaximizeButton; ComputeMaximizeButtonRect(rectMaximizeButton); ClientToScreen(&rectMaximizeButton); if (::PtInRect(&rectMaximizeButton, *ptHit)) return HTMAXBUTTON; RECT rectMinimizeButton; ComputeMinimizeButtonRect(rectMinimizeButton); ClientToScreen(&rectMinimizeButton); if (::PtInRect(&rectMinimizeButton, *ptHit)) return HTMINBUTTON; RECT rectSysIcon; ComputeWindowIconRect(rectSysIcon); ClientToScreen(&rectSysIcon); if (::PtInRect(&rectSysIcon, *ptHit)) return HTSYSMENU; if (!IsZoomed()) { // Left Border if (ptHit->x >= rectWindow.left && ptHit->x <= rectWindow.left + ::kWindowFrameSize) { // it's important that we know if the mouse is on a corner so that // the right mouse cursor is displayed if (ptHit->y <= rectWindow.top + ::kWindowFrameSize) return HTTOPLEFT; if (ptHit->y >= rectWindow.bottom - ::kWindowFrameSize) return HTBOTTOMLEFT; return HTLEFT; } // Right Border if (ptHit->x <= rectWindow.right && ptHit->x >= rectWindow.right - ::kWindowFrameSize) { // it's important that we know if the mouse is on a corner so that // the right mouse cursor is displayed if (ptHit->y <= rectWindow.top + ::kWindowFrameSize) return HTTOPRIGHT; if (ptHit->y >= rectWindow.bottom - ::kWindowFrameSize) return HTBOTTOMRIGHT; return HTRIGHT; } // Top and Bottom Borders if (ptHit->y <= rectWindow.top + ::kWindowFrameSize) return HTTOP; if (ptHit->y >= rectWindow.bottom - ::kWindowFrameSize) return HTBOTTOM; } RECT rectMenu; ComputeRequiredMenuRect(rectMenu); ClientToScreen(&rectMenu); if (::PtInRect(&rectMenu, *ptHit)) return HTMENU; // If it's in the menu bar but not actually // on a menu item, then return caption so // the window can be dragged from the dead space ComputeMenuBarRect(rectMenu); ClientToScreen(&rectMenu); if (::PtInRect(&rectMenu, *ptHit)) return HTCAPTION; // Aero requires that we return HTNOWHERE return HTNOWHERE; }
// WM_NCHITTEST handler int cef_dark_window::HandleNcHitTest(LPPOINT ptHit) { RECT rectWindow; GetWindowRect(&rectWindow); if (!::PtInRect(&rectWindow, *ptHit)) return HTNOWHERE; RECT rectClient; GetClientRect(&rectClient); ClientToScreen(&rectClient); if (::PtInRect(&rectClient, *ptHit)) return HTCLIENT; RECT rectCaption; ComputeWindowCaptionRect(rectCaption); NonClientToScreen(&rectCaption); if (::PtInRect(&rectCaption, *ptHit)) return HTCAPTION; RECT rectCloseButton; ComputeCloseButtonRect(rectCloseButton); NonClientToScreen(&rectCloseButton); if (::PtInRect(&rectCloseButton, *ptHit)) return HTCLOSE; RECT rectMaximizeButton; ComputeMaximizeButtonRect(rectMaximizeButton); NonClientToScreen(&rectMaximizeButton); if (::PtInRect(&rectMaximizeButton, *ptHit)) return HTMAXBUTTON; RECT rectMinimizeButton; ComputeMinimizeButtonRect(rectMinimizeButton); NonClientToScreen(&rectMinimizeButton); if (::PtInRect(&rectMinimizeButton, *ptHit)) return HTMINBUTTON; RECT rectSysIcon; ComputeWindowIconRect(rectSysIcon); NonClientToScreen(&rectSysIcon); if (::PtInRect(&rectSysIcon, *ptHit)) return HTSYSMENU; // Left Border if (ptHit->x >= rectWindow.left && ptHit->x <= rectWindow.left + ::GetSystemMetrics (SM_CYFRAME)) { // it's important that we know if the mouse is on a corner so that // the right mouse cursor is displayed if (ptHit->y <= rectWindow.top + ::GetSystemMetrics (SM_CYFRAME)) return HTTOPLEFT; if (ptHit->y >= rectWindow.bottom - ::GetSystemMetrics (SM_CYFRAME)) return HTBOTTOMLEFT; return HTLEFT; } // Right Border if (ptHit->x <= rectWindow.right && ptHit->x >= rectWindow.right - ::GetSystemMetrics (SM_CYFRAME)) { // it's important that we know if the mouse is on a corner so that // the right mouse cursor is displayed if (ptHit->y <= rectWindow.top + ::GetSystemMetrics (SM_CYFRAME)) return HTTOPRIGHT; if (ptHit->y >= rectWindow.bottom - ::GetSystemMetrics (SM_CYFRAME)) return HTBOTTOMRIGHT; return HTRIGHT; } // Top and Bottom Borders if (ptHit->y <= rectWindow.top + ::GetSystemMetrics (SM_CYFRAME)) return HTTOP; if (ptHit->y >= rectWindow.bottom - ::GetSystemMetrics (SM_CYFRAME)) return HTBOTTOM; // If it's not in the menu, it's in the caption RECT rectMenu; ComputeRequiredMenuRect(rectMenu); NonClientToScreen(&rectMenu); if (::PtInRect(&rectMenu, *ptHit)) return HTMENU; return HTCAPTION; }