From: Vadim Zeitlin Date: Sat, 9 Jul 2011 23:36:32 +0000 (+0000) Subject: Immediately update MSW cursor when ::SetCursor(wxNullCursor) is called. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/fd2eccd140ac70b80f4c92ab568a13628418622f Immediately update MSW cursor when ::SetCursor(wxNullCursor) is called. The cursor was previously reverted to the default one only when a next mouse event was received. Do it immediately now to e.g. avoid showing the busy cursor when the program is not busy any more. Closes #12961. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68208 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 609a1a4b31..cd72c3c1e6 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -829,6 +829,7 @@ bool wxWindowMSW::SetFont(const wxFont& font) return true; } + bool wxWindowMSW::SetCursor(const wxCursor& cursor) { if ( !wxWindowBase::SetCursor(cursor) ) @@ -838,7 +839,10 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor) } // don't "overwrite" busy cursor - if ( m_cursor.IsOk() && !wxIsBusy() ) + if ( wxIsBusy() ) + return true; + + if ( m_cursor.IsOk() ) { // normally we should change the cursor only if it's over this window // but we should do it always if we capture the mouse currently @@ -865,6 +869,26 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor) } //else: will be set later when the mouse enters this window } + else // Invalid cursor: this means reset to the default one. + { + // To revert to the correct cursor we need to find the window currently + // under the cursor and ask it to set its cursor itself as only it + // knows what it is. + POINT pt; + if ( !::GetCursorPos(&pt) ) + { + wxLogLastError(wxT("GetCursorPos")); + return false; + } + + const wxWindow* win = wxFindWindowAtPoint(wxPoint(pt.x, pt.y)); + if ( !win ) + win = this; + + ::SendMessage(GetHwndOf(win), WM_SETCURSOR, + (WPARAM)GetHwndOf(win), + MAKELPARAM(HTCLIENT, WM_MOUSEMOVE)); + } return true; }