LRESULT VirtualDimension::OnTimer(HWND /*hWnd*/, UINT /*message*/, WPARAM /*wParam*/, LPARAM /*lParam*/) { POINT pt; //Do not shrink and let the timer run if the mouse is over the window -> it will be hidden later, when //mouse is not on window anymore. GetCursorPos(&pt); if (!IsPointInWindow(pt) && GetWindowThreadProcessId(GetForegroundWindow(),NULL) != GetCurrentThreadId()) { KillTimer(m_autoHideTimerId); //already auto-hidden -> do not need to Shrink(); } return 0; }
static HWND FindTopmostWindowAtPoint(HWND aWnd, const POINT& aPointInScreen) { if (!::IsWindowVisible(aWnd) || !IsPointInWindow(aWnd, aPointInScreen)) { return nullptr; } HWND childWnd = ::GetTopWindow(aWnd); while (childWnd) { HWND topmostWnd = FindTopmostWindowAtPoint(childWnd, aPointInScreen); if (topmostWnd) { return topmostWnd; } childWnd = ::GetNextWindow(childWnd, GW_HWNDNEXT); } return aWnd; }