Replace wxTextCtrl::MSWWindowProc() with MSWHandleMessage()

Override newer and more flexible virtual method: this doesn't change anything
yet but will allow to provide default handling for some messages in a single
overridden method in the future commits, when it would have required to also
override MSWDefWindowProc() with the old method.
This commit is contained in:
Vadim Zeitlin
2015-11-18 23:32:14 +01:00
parent 6b2a6baf2e
commit 9bcaa058a0
2 changed files with 23 additions and 7 deletions

View File

@@ -181,7 +181,10 @@ public:
void OnSetFocus(wxFocusEvent& event); void OnSetFocus(wxFocusEvent& event);
// intercept WM_GETDLGCODE // intercept WM_GETDLGCODE
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual bool MSWHandleMessage(WXLRESULT *result,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam);
virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg); virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;

View File

@@ -2058,14 +2058,27 @@ void wxTextCtrl::OnKeyDown(wxKeyEvent& event)
event.Skip(); event.Skip();
} }
WXLRESULT wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) bool
wxTextCtrl::MSWHandleMessage(WXLRESULT *rc,
WXUINT nMsg,
WXWPARAM wParam,
WXLPARAM lParam)
{ {
WXLRESULT lRc = wxTextCtrlBase::MSWWindowProc(nMsg, wParam, lParam); bool processed = wxTextCtrlBase::MSWHandleMessage(rc, nMsg, wParam, lParam);
switch ( nMsg ) switch ( nMsg )
{ {
case WM_GETDLGCODE: case WM_GETDLGCODE:
{ {
// Ensure that the result value is initialized even if the base
// class didn't handle WM_GETDLGCODE but just update the value
// returned by it if it did handle it.
if ( !processed )
{
*rc = MSWDefWindowProc(nMsg, wParam, lParam);
processed = true;
}
// we always want the chars and the arrows: the arrows for // we always want the chars and the arrows: the arrows for
// navigation and the chars because we want Ctrl-C to work even // navigation and the chars because we want Ctrl-C to work even
// in a read only control // in a read only control
@@ -2089,7 +2102,7 @@ WXLRESULT wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
if ( HasFlag(wxTE_PROCESS_TAB) ) if ( HasFlag(wxTE_PROCESS_TAB) )
lDlgCode |= DLGC_WANTTAB; lDlgCode |= DLGC_WANTTAB;
lRc |= lDlgCode; *rc |= lDlgCode;
} }
else // !editable else // !editable
{ {
@@ -2098,11 +2111,11 @@ WXLRESULT wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
// including DLGC_WANTMESSAGE). This is strange (how // including DLGC_WANTMESSAGE). This is strange (how
// does it work in the native Win32 apps?) but for now // does it work in the native Win32 apps?) but for now
// live with it. // live with it.
lRc = lDlgCode; *rc = lDlgCode;
} }
if (IsMultiLine()) if (IsMultiLine())
// Clear the DLGC_HASSETSEL bit from the return value // Clear the DLGC_HASSETSEL bit from the return value
lRc &= ~DLGC_HASSETSEL; *rc &= ~DLGC_HASSETSEL;
} }
break; break;
@@ -2122,7 +2135,7 @@ WXLRESULT wxTextCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
#endif // wxUSE_MENUS #endif // wxUSE_MENUS
} }
return lRc; return processed;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------