X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/40ff126ac4ff57ab4aa22a5c7c7ce621479e8739..c259ffdff79ed1cb412cc829a19558064ce87474:/src/msw/textctrl.cpp diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index c2c88e5525..d893afe8d5 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -258,10 +258,49 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_SET_FOCUS(wxTextCtrl::OnSetFocus) END_EVENT_TABLE() +// ---------------------------------------------------------------------------- +// function prototypes +// ---------------------------------------------------------------------------- + +LRESULT APIENTRY _EXPORT wxTextCtrlWndProc(HWND hWnd, + UINT message, + WPARAM wParam, + LPARAM lParam); + +// --------------------------------------------------------------------------- +// global vars +// --------------------------------------------------------------------------- + +// the pointer to standard text control wnd proc +static WNDPROC gs_wndprocEdit = (WNDPROC)NULL; + // ============================================================================ // implementation // ============================================================================ +// ---------------------------------------------------------------------------- +// wnd proc for subclassed edit control +// ---------------------------------------------------------------------------- + +LRESULT APIENTRY _EXPORT wxTextCtrlWndProc(HWND hWnd, + UINT message, + WPARAM wParam, + LPARAM lParam) +{ + wxWindow *win = wxFindWinFromHandle((WXHWND)hWnd); + + switch ( message ) + { + case WM_CUT: + case WM_COPY: + case WM_PASTE: + if( win->HandleClipboardEvent( message ) ) + return 0; + break; + } + return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam); +} + // ---------------------------------------------------------------------------- // creation // ---------------------------------------------------------------------------- @@ -479,6 +518,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, } #endif // wxUSE_RICHEDIT + gs_wndprocEdit = wxSetWindowProc((HWND)GetHwnd(), + wxTextCtrlWndProc); + return true; } @@ -749,20 +791,24 @@ void wxTextCtrl::SetValue(const wxString& value) { DoWriteText(value, false /* not selection only */); + // mark the control as being not dirty - we changed its text, not the + // user + DiscardEdits(); + // for compatibility, don't move the cursor when doing SetValue() SetInsertionPoint(0); } else // same text { + // still reset the modified flag even if the value didn't really change + // because now it comes from the program and not the user (and do it + // before generating the event so that the event handler could get the + // expected value from IsModified()) + DiscardEdits(); + // still send an event for consistency SendUpdateEvent(); } - - // we should reset the modified flag even if the value didn't really change - - // mark the control as being not dirty - we changed its text, not the - // user - DiscardEdits(); } #if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU)