// 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); 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; 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); NonClientToScreen(&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); NonClientToScreen(&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; }