+//////////////////////////////////////////////////////////////////////////////
+//
+// Give all windows a chance to preprocess
+// the message. Some may have accelerator tables, or have
+// MDI complications.
+//
+//////////////////////////////////////////////////////////////////////////////
+bool wxApp::ProcessMessage(
+ WXMSG* pWxmsg
+)
+{
+ QMSG* pMsg = (PQMSG)pWxmsg;
+ HWND hWnd = pMsg->hwnd;
+ wxWindow* pWndThis = wxFindWinFromHandle((WXHWND)hWnd);
+ wxWindow* pWnd;
+
+#if wxUSE_TOOLTIPS
+ //
+ // We must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to
+ // popup the tooltip bubbles
+ //
+ if (pWndThis && (pMsg->msg == WM_MOUSEMOVE))
+ {
+ wxToolTip* pToolTip = pWndThis->GetToolTip();
+ if (pToolTip)
+ {
+ pToolTip->RelayEvent(pWxmsg);
+ }
+ }
+#endif // wxUSE_TOOLTIPS
+
+ //
+ // We must relay Timer events to wxTimer's processing function
+ //
+ if (pMsg->msg == WM_TIMER)
+ wxTimerProc(NULL, 0, (int)pMsg->mp1, 0);
+
+ //
+ // For some composite controls (like a combobox), wndThis might be NULL
+ // because the subcontrol is not a wxWindow, but only the control itself
+ // is - try to catch this case
+ //
+ while (hWnd && !pWndThis)
+ {
+ hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
+ pWndThis = wxFindWinFromHandle((WXHWND)hWnd);
+ }
+
+ //
+ // Try translations first; find the youngest window with
+ // a translation table. OS/2 has case sensative accels, so
+ // this block, coded by BK, removes that and helps make them
+ // case insensative.
+ //
+ if(pMsg->msg == WM_CHAR)
+ {
+ PBYTE pChmsg = (PBYTE)&(pMsg->msg);
+ USHORT uSch = CHARMSG(pChmsg)->chr;
+ bool bRc;
+
+ //
+ // Do not process keyup events
+ //
+ if(!(CHARMSG(pChmsg)->fs & KC_KEYUP))
+ {
+ if((CHARMSG(pChmsg)->fs & (KC_ALT | KC_CTRL)) && CHARMSG(pChmsg)->chr != 0)
+ CHARMSG(pChmsg)->chr = (USHORT)wxToupper((UCHAR)uSch);
+
+
+ for(pWnd = pWndThis; pWnd; pWnd = pWnd->GetParent() )
+ {
+ if((bRc = pWnd->OS2TranslateMessage(pWxmsg)) == TRUE)
+ break;
+ }
+
+ if(!bRc) // untranslated, should restore original value
+ CHARMSG(pChmsg)->chr = uSch;
+ }
+ }
+ //
+ // Anyone for a non-translation message? Try youngest descendants first.
+ //
+// for (pWnd = pWndThis; pWnd; pWnd = pWnd->GetParent())
+// {
+// if (pWnd->OS2ProcessMessage(pWxmsg))
+// return TRUE;
+// }
+ return FALSE;
+} // end of wxApp::ProcessMessage
+
+void wxApp::OnIdle(
+ wxIdleEvent& rEvent
+)
+{
+ static bool sbInOnIdle = FALSE;
+
+ //
+ // Avoid recursion (via ProcessEvent default case)
+ //
+ if (sbInOnIdle)
+ return;
+
+ sbInOnIdle = TRUE;
+
+ //
+ // If there are pending events, we must process them: pending events
+ // are either events to the threads other than main or events posted
+ // with wxPostEvent() functions
+ //
+ ProcessPendingEvents();
+
+ //
+ // 'Garbage' collection of windows deleted with Close().
+ //
+ DeletePendingObjects();
+
+#if wxUSE_LOG
+ //
+ // Flush the logged messages if any
+ //
+ wxLog::FlushActive();
+#endif // wxUSE_LOG
+
+#if wxUSE_DC_CACHEING
+ // automated DC cache management: clear the cached DCs and bitmap
+ // if it's likely that the app has finished with them, that is, we
+ // get an idle event and we're not dragging anything.
+ if (!::WinGetKeyState(MK_LBUTTON) &&
+ !::WinGetKeyState(MK_MBUTTON) &&
+ !::WinGetKeyState(MK_RBUTTON))
+ wxDC::ClearCache();
+#endif // wxUSE_DC_CACHEING
+
+ //
+ // Send OnIdle events to all windows
+ //
+ if (SendIdleEvents())
+ {
+ //
+ // SendIdleEvents() returns TRUE if at least one window requested more
+ // idle events
+ //
+ rEvent.RequestMore(TRUE);
+ }
+ sbInOnIdle = FALSE;
+} // end of wxApp::OnIdle
+
+// Send idle event to all top-level windows
+bool wxApp::SendIdleEvents()
+{
+ bool bNeedMore = FALSE;
+ wxWindowList::Node* pNode = wxTopLevelWindows.GetFirst();
+
+ while (pNode)
+ {
+ wxWindow* pWin = pNode->GetData();
+
+ if (SendIdleEvents(pWin))
+ bNeedMore = TRUE;
+ pNode = pNode->GetNext();
+ }
+ return bNeedMore;
+} // end of wxApp::SendIdleEvents
+
+//
+// Send idle event to window and all subwindows
+//
+bool wxApp::SendIdleEvents(
+ wxWindow* pWin
+)