From 101f488cf501c1ad651e81e6c15bfc7705634331 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 19 Jun 1999 00:08:58 +0000 Subject: [PATCH] text controls respect wxTE_PROCESS_ENTER/TAB styles again, WM_GETDLGCODE handling is generally better git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2827 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/textctrl.h | 1 - include/wx/msw/window.h | 15 +++++++++------ src/msw/textctrl.cpp | 35 +++++++++++++++-------------------- src/msw/window.cpp | 19 +++++++++++++++++-- 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index 46f240ad91..6461338618 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -181,7 +181,6 @@ public: virtual void AdoptAttributesFromHWND(); virtual void SetupColours(); - virtual long MSWGetDlgCode(); protected: #if wxUSE_RICHEDIT diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 3d4c2a2ad1..0cfca8bfc5 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -296,12 +296,12 @@ public: bool HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam); bool HandleCtlColor(WXHBRUSH *hBrush, - WXHDC hdc, - WXHWND hWnd, - WXUINT nCtlColor, - WXUINT message, - WXWPARAM wParam, - WXLPARAM lParam); + WXHDC hdc, + WXHWND hWnd, + WXUINT nCtlColor, + WXUINT message, + WXWPARAM wParam, + WXLPARAM lParam); bool HandlePaletteChanged(WXHWND hWndPalChange); bool HandleQueryNewPalette(); @@ -385,6 +385,9 @@ protected: WXHMENU m_hMenu; // Menu, if any + // the return value of WM_GETDLGCODE handler + long m_lDlgCode; + // implement the base class pure virtuals virtual void DoClientToScreen( int *x, int *y ) const; virtual void DoScreenToClient( int *x, int *y ) const; diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 65b1f25222..db6f5009c4 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -151,6 +151,21 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if (m_windowStyle & wxTE_PASSWORD) // hidden input msStyle |= ES_PASSWORD; + // we always want the characters and the arrows + m_lDlgCode = DLGC_WANTCHARS | DLGC_WANTARROWS; + + // we may have several different cases: + // 1. normal case: both TAB and ENTER are used for dialog navigation + // 2. ctrl which wants TAB for itself: ENTER is used to pass to the next + // control in the dialog + // 3. ctrl which wants ENTER for itself: TAB is used for dialog navigation + // 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass to + // the next control + if ( m_windowStyle & wxTE_PROCESS_ENTER ) + m_lDlgCode |= DLGC_WANTMESSAGE; + if ( m_windowStyle & wxTE_PROCESS_TAB ) + m_lDlgCode |= DLGC_WANTTAB; + const wxChar *windowClass = _T("EDIT"); #if wxUSE_RICHEDIT @@ -1123,26 +1138,6 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) event.Skip(); } -long wxTextCtrl::MSWGetDlgCode() -{ - // we always want the characters and the arrows - long lRc = DLGC_WANTCHARS | DLGC_WANTARROWS; - - // we may have several different cases: - // 1. normal case: both TAB and ENTER are used for dialog navigation - // 2. ctrl which wants TAB for itself: ENTER is used to pass to the next - // control in the dialog - // 3. ctrl which wants ENTER for itself: TAB is used for dialog navigation - // 4. ctrl which wants both TAB and ENTER: Ctrl-ENTER is used to pass to - // the next control - if ( m_windowStyle & wxTE_PROCESS_ENTER ) - lRc |= DLGC_WANTMESSAGE; - if ( m_windowStyle & wxTE_PROCESS_TAB ) - lRc |= DLGC_WANTTAB; - - return lRc; -} - bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) { switch (param) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index d0f8984af8..5a5d8f6434 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -317,6 +317,20 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, msflags |= WS_BORDER; } + // calculate the value to return from WM_GETDLGCODE handler + if ( GetWindowStyleFlag() & wxWANTS_CHARS ) + { + // want everything: i.e. all keys and WM_CHAR message + m_lDlgCode = DLGC_WANTARROWS | DLGC_WANTCHARS | + DLGC_WANTTAB | DLGC_WANTMESSAGE; + + } + else + { + // default behaviour + m_lDlgCode = 0; + } + MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL, pos.x, pos.y, WidthDefault(size.x), HeightDefault(size.y), @@ -1756,11 +1770,12 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) break; case WM_GETDLGCODE: - if ( GetWindowStyleFlag() & wxWANTS_CHARS ) + if ( m_lDlgCode ) { - rc.result = DLGC_WANTARROWS | DLGC_WANTCHARS | DLGC_WANTTAB; + rc.result = m_lDlgCode; processed = TRUE; } + //else: get the dlg code from the DefWindowProc() break; case WM_KEYDOWN: -- 2.45.2