Refactor wxWindow::MSWHandleMessage() out from MSWWindowProc().

This commit just refactors the code without changing anything in its
behaviour and will be followed by the real changes in the next one.

The new function just handles the message, without calling MSWDefWindowProc()
if it wasn't handled. This allows to call it and determine whether the message
was really handled and only continue processing it if it wasn't.

Notice that while in theory this shouldn't be necessary because the return
value of MSWWindowProc() should indicate whether the message was handled or
not (0 meaning that it was, for most messages), in practice it doesn't work
because many standard controls window procs return 0 even for message they do
nothing with, e.g. "up down" control always returns 0 for WM_CHAR messages
even it it only really handles the arrow keys.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68327 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-07-22 12:49:22 +00:00
parent 41936464fd
commit 2e1cee233e
2 changed files with 33 additions and 4 deletions

View File

@@ -2728,7 +2728,11 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM w
return rc;
}
WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
bool
wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam)
{
// did we process the message?
bool processed = false;
@@ -3608,15 +3612,26 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
}
if ( !processed )
return false;
*result = rc.result;
return true;
}
WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
WXLRESULT result;
if ( !MSWHandleMessage(&result, message, wParam, lParam) )
{
#if wxDEBUG_LEVEL >= 2
wxLogTrace("winmsg", wxT("Forwarding %s to DefWindowProc."),
wxGetMessageName(message));
#endif // wxDEBUG_LEVEL >= 2
rc.result = MSWDefWindowProc(message, wParam, lParam);
result = MSWDefWindowProc(message, wParam, lParam);
}
return rc.result;
return result;
}
// ----------------------------------------------------------------------------