+ HWND hwnd = msg->hwnd;
+ wxWindow *wndThis = wxGetWindowFromHWND((WXHWND)hwnd);
+
+ // this may happen if the event occured in a standard modeless dialog (the
+ // only example of which I know of is the find/replace dialog) - then call
+ // IsDialogMessage() to make TAB navigation in it work
+ if ( !wndThis )
+ {
+ // we need to find the dialog containing this control as
+ // IsDialogMessage() just eats all the messages (i.e. returns TRUE for
+ // them) if we call it for the control itself
+ while ( hwnd && ::GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD )
+ {
+ hwnd = ::GetParent(hwnd);
+ }
+
+ return hwnd && ::IsDialogMessage(hwnd, msg) != 0;
+ }