X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c0cdd6ccd039e14562a3b38e94da7dba86e5d3a7..9f39393d9efe16244c8d213076582dfd996cb129:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index b3a276a34a..27298fab61 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -131,7 +131,6 @@ extern MSG s_currentMsg; wxMenu *wxCurrentPopupMenu = NULL; #endif // wxUSE_MENUS_NATIVE -extern wxList WXDLLEXPORT wxPendingDelete; extern const wxChar *wxCanvasClassName; // --------------------------------------------------------------------------- @@ -770,6 +769,15 @@ int wxWindowMSW::GetScrollPage(int orient) const #endif // WXWIN_COMPATIBILITY +inline int GetScrollPosition(HWND hWnd, int wOrient) +{ +#ifdef __WXMICROWIN__ + return ::GetScrollPosWX(hWnd, wOrient); +#else + return ::GetScrollPos(hWnd, wOrient); +#endif +} + int wxWindowMSW::GetScrollPos(int orient) const { int wOrient; @@ -777,17 +785,11 @@ int wxWindowMSW::GetScrollPos(int orient) const wOrient = SB_HORZ; else wOrient = SB_VERT; + HWND hWnd = GetHwnd(); - if ( hWnd ) - { -#ifdef __WXMICROWIN__ - return ::GetScrollPosWX(hWnd, wOrient); -#else - return ::GetScrollPos(hWnd, wOrient); -#endif - } - else - return 0; + wxCHECK_MSG( hWnd, 0, _T("no HWND in GetScrollPos") ); + + return GetScrollPosition(hWnd, wOrient); } // This now returns the whole range, not just the number @@ -940,30 +942,44 @@ void wxWindowMSW::ScrollWindow(int dx, int dy, const wxRect *prect) ::ScrollWindow(GetHwnd(), dx, dy, prect ? &rect : NULL, NULL); } -static void ScrollVertically(HWND hwnd, int kind, int count) +static bool ScrollVertically(HWND hwnd, int kind, int count) { + int posStart = GetScrollPosition(hwnd, SB_VERT); + + int pos = posStart; for ( int n = 0; n < count; n++ ) { ::SendMessage(hwnd, WM_VSCROLL, kind, 0); + + int posNew = GetScrollPosition(hwnd, SB_VERT); + if ( posNew == pos ) + { + // don't bother to continue, we're already at top/bottom + break; + } + + pos = posNew; } + + return pos != posStart; } -void wxWindowMSW::ScrollLines(int lines) +bool wxWindowMSW::ScrollLines(int lines) { bool down = lines > 0; - ScrollVertically(GetHwnd(), - down ? SB_LINEDOWN : SB_LINEUP, - down ? lines : -lines); + return ScrollVertically(GetHwnd(), + down ? SB_LINEDOWN : SB_LINEUP, + down ? lines : -lines); } -void wxWindowMSW::ScrollPages(int pages) +bool wxWindowMSW::ScrollPages(int pages) { bool down = pages > 0; - ScrollVertically(GetHwnd(), - down ? SB_PAGEDOWN : SB_PAGEUP, - down ? pages : -pages); + return ScrollVertically(GetHwnd(), + down ? SB_PAGEDOWN : SB_PAGEUP, + down ? pages : -pages); } // --------------------------------------------------------------------------- @@ -3116,6 +3132,16 @@ bool wxWindowMSW::HandleSetFocus(WXHWND hwnd) } #endif // wxUSE_CARET +#if wxUSE_TEXTCTRL + // If it's a wxTextCtrl don't send the event as it will be done + // after the control gets to process it. + wxTextCtrl *ctrl = wxDynamicCastThis(wxTextCtrl); + if ( ctrl ) + { + return FALSE; + } +#endif + wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); event.SetEventObject(this); @@ -3135,6 +3161,16 @@ bool wxWindowMSW::HandleKillFocus(WXHWND hwnd) } #endif // wxUSE_CARET +#if wxUSE_TEXTCTRL + // If it's a wxTextCtrl don't send the event as it will be done + // after the control gets to process it. + wxTextCtrl *ctrl = wxDynamicCastThis(wxTextCtrl); + if ( ctrl ) + { + return FALSE; + } +#endif + wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId); event.SetEventObject(this); @@ -4377,19 +4413,27 @@ extern wxWindow *wxGetWindowFromHWND(WXHWND hWnd) #endif // wxUSE_SPINCTRL #endif // Win32 - - if ( !win ) - { - // hwnd is not a wxWindow, try its parent next below - hwnd = ::GetParent(hwnd); - } } } while ( hwnd && !win ) { - win = wxFindWinFromHandle((WXHWND)hwnd); + // this is a really ugly hack needed to avoid mistakenly returning the + // parent frame wxWindow for the find/replace modeless dialog HWND - + // this, in turn, is needed to call IsDialogMessage() from + // wxApp::ProcessMessage() as for this we must return NULL from here + // + // FIXME: this is clearly not the best way to do it but I think we'll + // need to change HWND <-> wxWindow code more heavily than I can + // do it now to fix it + if ( ::GetWindow(hwnd, GW_OWNER) ) + { + // it's a dialog box, don't go upwards + break; + } + hwnd = ::GetParent(hwnd); + win = wxFindWinFromHandle((WXHWND)hwnd); } return win;