we don't need to subclass text control twice to implement support for WM_COPY/CUT/PASTE, just handle them in MSWWindowProc() (this reimplements the change of rev 1.261 correctly)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44019 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-12-20 09:51:50 +00:00
parent 5b204a088a
commit 9fcbe07663

View File

@@ -263,50 +263,10 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
EVT_SET_FOCUS(wxTextCtrl::OnSetFocus) EVT_SET_FOCUS(wxTextCtrl::OnSetFocus)
END_EVENT_TABLE() 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 // implementation
// ============================================================================ // ============================================================================
// ----------------------------------------------------------------------------
// wnd proc for subclassed edit control
// ----------------------------------------------------------------------------
LRESULT APIENTRY _EXPORT wxTextCtrlWndProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch ( message )
{
case WM_CUT:
case WM_COPY:
case WM_PASTE:
{
wxWindow *win = wxFindWinFromHandle((WXHWND)hWnd);
if( win->HandleClipboardEvent( message ) )
return 0;
break;
}
}
return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// creation // creation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -524,9 +484,6 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
} }
#endif // wxUSE_RICHEDIT #endif // wxUSE_RICHEDIT
gs_wndprocEdit = wxSetWindowProc((HWND)GetHwnd(),
wxTextCtrlWndProc);
return true; return true;
} }
@@ -1923,41 +1880,53 @@ WXLRESULT wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
{ {
WXLRESULT lRc = wxTextCtrlBase::MSWWindowProc(nMsg, wParam, lParam); WXLRESULT lRc = wxTextCtrlBase::MSWWindowProc(nMsg, wParam, lParam);
if ( nMsg == WM_GETDLGCODE ) switch ( nMsg )
{ {
// we always want the chars and the arrows: the arrows for navigation case WM_GETDLGCODE:
// and the chars because we want Ctrl-C to work even in a read only {
// control // we always want the chars and the arrows: the arrows for
long lDlgCode = DLGC_WANTCHARS | DLGC_WANTARROWS; // navigation and the chars because we want Ctrl-C to work even
// in a read only control
long lDlgCode = DLGC_WANTCHARS | DLGC_WANTARROWS;
if ( IsEditable() ) if ( IsEditable() )
{ {
// we may have several different cases: // we may have several different cases:
// 1. normal case: both TAB and ENTER are used for dlg navigation // 1. normal: both TAB and ENTER are used for navigation
// 2. ctrl which wants TAB for itself: ENTER is used to pass to the // 2. ctrl wants TAB for itself: ENTER is used to pass to
// next control in the dialog // the next control in the dialog
// 3. ctrl which wants ENTER for itself: TAB is used for dialog // 3. ctrl wants ENTER for itself: TAB is used for dialog
// navigation // navigation
// 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to go // 4. ctrl wants both TAB and ENTER: Ctrl-ENTER is used to
// to the next control // go to the next control (we need some way to do it)
// the multiline edit control should always get <Return> for itself // multiline controls should always get ENTER for themselves
if ( HasFlag(wxTE_PROCESS_ENTER) || HasFlag(wxTE_MULTILINE) ) if ( HasFlag(wxTE_PROCESS_ENTER) || HasFlag(wxTE_MULTILINE) )
lDlgCode |= DLGC_WANTMESSAGE; lDlgCode |= DLGC_WANTMESSAGE;
if ( HasFlag(wxTE_PROCESS_TAB) ) if ( HasFlag(wxTE_PROCESS_TAB) )
lDlgCode |= DLGC_WANTTAB; lDlgCode |= DLGC_WANTTAB;
lRc |= lDlgCode; lRc |= lDlgCode;
} }
else // !editable else // !editable
{ {
// NB: use "=", not "|=" as the base class version returns the // NB: use "=", not "|=" as the base class version returns
// same flags is this state as usual (i.e. including // the same flags is this state as usual (i.e.
// DLGC_WANTMESSAGE). This is strange (how does it work in the // including DLGC_WANTMESSAGE). This is strange (how
// native Win32 apps?) but for now live with it. // does it work in the native Win32 apps?) but for now
lRc = lDlgCode; // live with it.
} lRc = lDlgCode;
}
}
break;
case WM_CUT:
case WM_COPY:
case WM_PASTE:
if ( HandleClipboardEvent(nMsg) )
lRc = 0;
break;
} }
return lRc; return lRc;