]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/app.cpp
Add space all around std buttons as per Apple HIG (and as the comment in the code...
[wxWidgets.git] / src / os2 / app.cpp
index 50a810d166a01d6b413612e7074cb0158d64256b..097b323973b9a93d52f664dcf8b53490ff05f366 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        app.cpp
+// Name:        src/os2/app.cpp
 // Purpose:     wxApp
 // Author:      David Webster
 // Modified by:
@@ -9,16 +9,14 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-    #pragma implementation "app.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
+#include "wx/app.h"
+
 #ifndef WX_PRECOMP
+    #include "wx/dynarray.h"
     #include "wx/frame.h"
-    #include "wx/app.h"
     #include "wx/utils.h"
     #include "wx/gdicmn.h"
     #include "wx/pen.h"
     #include "wx/dialog.h"
     #include "wx/msgdlg.h"
     #include "wx/intl.h"
-    #include "wx/dynarray.h"
-    #include "wx/wxchar.h"
-    #include "wx/icon.h"
-    #include "wx/timer.h"
+    #include "wx/crt.h"
+    #include "wx/log.h"
+    #include "wx/module.h"
 #endif
 
-#include "wx/log.h"
-#include "wx/module.h"
+#include "wx/stdpaths.h"
+#include "wx/filename.h"
+#include "wx/evtloop.h"
 
 #include "wx/os2/private.h"
 
 
 #endif //
 
-#ifndef __EMX__
+#if defined(__WATCOMC__)
+
+#include <tcpustd.h>
+
+#elif !defined(__EMX__)
 
 #define select(a,b,c,d,e) bsdselect(a,b,c,d,e)
 extern "C" int _System bsdselect(int,
@@ -67,13 +69,6 @@ extern "C" int _System bsdselect(int,
 
 #if wxUSE_THREADS
     #include "wx/thread.h"
-
-    // define the array of QMSG strutures
-    WX_DECLARE_OBJARRAY(QMSG, wxMsgArray);
-
-    #include "wx/arrimpl.cpp"
-
-    WX_DEFINE_OBJARRAY(wxMsgArray);
 #endif // wxUSE_THREADS
 
 #if wxUSE_TOOLTIPS
@@ -87,13 +82,10 @@ extern "C" int _System bsdselect(int,
 // global variables
 // ---------------------------------------------------------------------------
 
-extern wxChar*                      wxBuffer;
-extern wxList*                      wxWinHandleList;
-extern wxList WXDLLEXPORT           wxPendingDelete;
+WXDLLEXPORT_DATA(wxChar*) wxBuffer;
 extern wxCursor*                    g_globalCursor;
 
 HAB                                 vHabmain = NULLHANDLE;
-QMSG                                svCurrentMsg;
 
 
 HICON wxSTD_FRAME_ICON          = (HICON) NULL;
@@ -124,38 +116,13 @@ struct GsocketCallbackInfo{
     void* gsock;
 };
 
-// These defines and wrapper functions are used here and in gsockpm.c
+// These defines are used here and in gsockpm.cpp
 #define wxSockReadMask  0x01
 #define wxSockWriteMask 0x02
 
-#ifdef __EMX__
-extern "C"
-int wxAppAddSocketHandler(int handle, int mask,
-                           void (*callback)(void*), void * gsock)
-{
-    return wxTheApp->AddSocketHandler(handle, mask, callback, gsock);
-}
-extern "C"
-void wxAppRemoveSocketHandler(int handle)
-{
-    wxTheApp->RemoveSocketHandler(handle);
-}
-#else
-//  Linkage mode problems using callbacks with extern C in a .cpp module
-int wxAppAddSocketHandler(int handle, int mask,
-                           void (*callback)(void*), void * gsock)
-{
-    return wxTheApp->AddSocketHandler(handle, mask, callback, gsock);
-}
-void wxAppRemoveSocketHandler(int handle)
-{
-    wxTheApp->RemoveSocketHandler(handle);
-}
-#endif
-
 void wxApp::HandleSockets()
 {
-    bool pendingEvent = FALSE;
+    bool pendingEvent = false;
 
     // Check whether it's time for Gsocket operation
     if (m_maxSocketHandles > 0 && m_maxSocketNr > 0)
@@ -184,7 +151,7 @@ void wxApp::HandleSockets()
                     if (r < m_maxSocketHandles)
                     {
                         CallbackInfo[r].proc(CallbackInfo[r].gsock);
-                        pendingEvent = TRUE;
+                        pendingEvent = true;
                     }
                 }
                 if (FD_ISSET(i, &writefds))
@@ -197,7 +164,7 @@ void wxApp::HandleSockets()
                     if (r < m_maxSocketHandles)
                     {
                         CallbackInfo[r].proc(CallbackInfo[r].gsock);
-                        pendingEvent = TRUE;
+                        pendingEvent = true;
                     }
                 }
             }
@@ -253,13 +220,15 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
     // OS2 has to have an anchorblock
     //
     vHabmain = WinInitialize(0);
-
+    wxFileName GetPrefix(argv[0]);
+    GetPrefix.MakeAbsolute();
+    wxStandardPaths::SetInstallPrefix(GetPrefix.GetPath());
     if (!vHabmain)
     {
         // TODO: at least give some error message here...
         wxAppBase::CleanUp();
 
-        return FALSE;
+        return false;
     }
 
     wxBuffer = new wxChar[1500]; // FIXME; why?
@@ -270,7 +239,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
     //    wxRedirectIOToConsole();
 #endif
 
-    wxWinHandleList = new wxList(wxKEY_INTEGER);
+    wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100);
 
     // This is to foil optimizations in Visual C++ that throw out dummy.obj.
     // PLEASE DO NOT ALTER THIS.
@@ -283,7 +252,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
 
     RegisterWindowClasses(vHabmain);
 
-    return TRUE;
+    return true;
 } // end of wxApp::Initialize
 
 const char*                         CANTREGISTERCLASS = " Can't register Class ";
@@ -291,15 +260,13 @@ const char*                         CANTREGISTERCLASS = " Can't register Class "
 // RegisterWindowClasses
 // ---------------------------------------------------------------------------
 
-bool wxApp::RegisterWindowClasses(
-  HAB                               vHab
-)
+bool wxApp::RegisterWindowClasses( HAB vHab )
 {
-    ERRORID                         vError = 0L;
-    wxString                        sError;
+    ERRORID vError = 0L;
+    wxString sError;
 
     if (!::WinRegisterClass( vHab
-                            ,wxFrameClassName
+                            ,(PSZ)wxFrameClassName
                             ,wxFrameWndProc
                             ,CS_SIZEREDRAW | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -307,12 +274,12 @@ bool wxApp::RegisterWindowClasses(
     {
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
-        wxLogLastError(sError);
-        return FALSE;
+        wxLogLastError(sError.c_str());
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxFrameClassNameNoRedraw
+                            ,(PSZ)wxFrameClassNameNoRedraw
                             ,wxWndProc
                             ,0
                             ,sizeof(ULONG)
@@ -320,12 +287,12 @@ bool wxApp::RegisterWindowClasses(
     {
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
-        wxLogLastError(sError);
-        return FALSE;
+        wxLogLastError(sError.c_str());
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxMDIFrameClassName
+                            ,(PSZ)wxMDIFrameClassName
                             ,wxWndProc
                             ,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -333,12 +300,12 @@ bool wxApp::RegisterWindowClasses(
     {
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
-        wxLogLastError(sError);
-        return FALSE;
+        wxLogLastError(sError.c_str());
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxMDIFrameClassNameNoRedraw
+                            ,(PSZ)wxMDIFrameClassNameNoRedraw
                             ,wxWndProc
                             ,0
                             ,sizeof(ULONG)
@@ -346,12 +313,12 @@ bool wxApp::RegisterWindowClasses(
     {
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
-        wxLogLastError(sError);
-        return FALSE;
+        wxLogLastError(sError.c_str());
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxMDIChildFrameClassName
+                            ,(PSZ)wxMDIChildFrameClassName
                             ,wxWndProc
                             ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST
                             ,sizeof(ULONG)
@@ -359,12 +326,12 @@ bool wxApp::RegisterWindowClasses(
     {
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
-        wxLogLastError(sError);
-        return FALSE;
+        wxLogLastError(sError.c_str());
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxMDIChildFrameClassNameNoRedraw
+                            ,(PSZ)wxMDIChildFrameClassNameNoRedraw
                             ,wxWndProc
                             ,CS_HITTEST
                             ,sizeof(ULONG)
@@ -372,12 +339,12 @@ bool wxApp::RegisterWindowClasses(
     {
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
-        wxLogLastError(sError);
-        return FALSE;
+        wxLogLastError(sError.c_str());
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxPanelClassName
+                            ,(PSZ)wxPanelClassName
                             ,wxWndProc
                             ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -385,12 +352,12 @@ bool wxApp::RegisterWindowClasses(
     {
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
-        wxLogLastError(sError);
-        return FALSE;
+        wxLogLastError(sError.c_str());
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxCanvasClassName
+                            ,(PSZ)wxCanvasClassName
                             ,wxWndProc
                             ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -398,11 +365,11 @@ bool wxApp::RegisterWindowClasses(
     {
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
-        wxLogLastError(sError);
-        return FALSE;
+        wxLogLastError(sError.c_str());
+        return false;
     }
     if (!::WinRegisterClass( vHab
-                            ,wxCanvasClassNameNR
+                            ,(PSZ)wxCanvasClassNameNR
                             ,wxWndProc
                             ,CS_HITTEST | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -410,14 +377,14 @@ bool wxApp::RegisterWindowClasses(
     {
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
-        wxLogLastError(sError);
-        return FALSE;
+        wxLogLastError(sError.c_str());
+        return false;
     }
-    return TRUE;
+    return true;
 } // end of wxApp::RegisterWindowClasses
 
 //
-// Cleans up any wxWindows internal structures left lying around
+// Cleans up any wxWidgets internal structures left lying around
 //
 void wxApp::CleanUp()
 {
@@ -428,7 +395,7 @@ void wxApp::CleanUp()
     // PM-SPECIFIC CLEANUP
     //
 
-    // wxSetKeyboardHook(FALSE);
+    // wxSetKeyboardHook(false);
 
     if (wxSTD_FRAME_ICON)
         ::WinFreeFileIcon(wxSTD_FRAME_ICON);
@@ -449,8 +416,8 @@ void wxApp::CleanUp()
 // TODO:        ::DeleteObject( wxDisableButtonBrush );
     }
 
-    if (wxWinHandleList)
-        delete wxWinHandleList;
+    delete wxWinHandleHash;
+    wxWinHandleHash = NULL;
 
     // Delete Message queue
     if (wxTheApp->m_hMq)
@@ -461,11 +428,11 @@ void wxApp::CleanUp()
 
 bool wxApp::OnInitGui()
 {
-    ERRORID                         vError;
-    wxString                        sError;
+    ERRORID vError;
+    wxString sError;
 
     if (!wxAppBase::OnInitGui())
-        return FALSE;
+        return false;
 
     m_hMq = ::WinCreateMsgQueue(vHabmain, 0);
     if (!m_hMq)
@@ -473,16 +440,14 @@ bool wxApp::OnInitGui()
         vError = ::WinGetLastError(vHabmain);
         sError = wxPMErrorToStr(vError);
         wxLogDebug(sError);
-        return FALSE;
+        return false;
     }
 
-    return TRUE;
+    return true;
 } // end of wxApp::OnInitGui
 
 wxApp::wxApp()
 {
-    argc = 0;
-    argv = NULL;
     m_nPrintMode = wxPRINT_WINDOWS;
     m_hMq = 0;
     m_maxSocketHandles = 0;
@@ -492,279 +457,19 @@ wxApp::wxApp()
 
 wxApp::~wxApp()
 {
-    //
-    // Delete command-line args
-    //
-#if wxUSE_UNICODE
-    int                             i;
-
-    for (i = 0; i < argc; i++)
-    {
-        delete[] argv[i];
-    }
-    delete[] argv;
-#endif
 } // end of wxApp::~wxApp
 
-bool wxApp::Initialized()
-{
-    if (GetTopWindow())
-        return TRUE;
-    else
-        return FALSE;
-} // end of wxApp::Initialized
-
-//
-// Get and process a message, returning FALSE if WM_QUIT
-// received (and also set the flag telling the app to exit the main loop)
-//
-
-bool wxApp::DoMessage()
-{
-    BOOL                            bRc = ::WinGetMsg(vHabmain, &svCurrentMsg, HWND(NULL), 0, 0);
-
-    if (bRc == 0)
-    {
-        // got WM_QUIT
-        m_bKeepGoing = FALSE;
-        return FALSE;
-    }
-    else if (bRc == -1)
-    {
-        // should never happen, but let's test for it nevertheless
-        wxLogLastError("GetMessage");
-    }
-    else
-    {
-#if wxUSE_THREADS
-        wxASSERT_MSG( wxThread::IsMain()
-                     ,wxT("only the main thread can process Windows messages")
-                    );
-
-        static bool                 sbHadGuiLock = TRUE;
-        static wxMsgArray           svSavedMessages;
-
-        //
-        // If a secondary thread owns is doing GUI calls, save all messages for
-        // later processing - we can't process them right now because it will
-        // lead to recursive library calls (and we're not reentrant)
-        //
-        if (!wxGuiOwnedByMainThread())
-        {
-            sbHadGuiLock = FALSE;
-
-            //
-            // Leave out WM_COMMAND messages: too dangerous, sometimes
-            // the message will be processed twice
-            //
-            if ( !wxIsWaitingForThread() ||
-                    svCurrentMsg.msg != WM_COMMAND )
-            {
-                svSavedMessages.Add(svCurrentMsg);
-            }
-            return TRUE;
-        }
-        else
-        {
-            //
-            // Have we just regained the GUI lock? if so, post all of the saved
-            // messages
-            //
-            if (!sbHadGuiLock )
-            {
-                sbHadGuiLock = TRUE;
-
-                size_t             nCount = svSavedMessages.Count();
+bool gbInOnIdle = false;
 
-                for (size_t n = 0; n < nCount; n++)
-                {
-                    QMSG            vMsg = svSavedMessages[n];
-
-                    DoMessage((WXMSG*)&vMsg);
-                }
-                svSavedMessages.Empty();
-            }
-        }
-#endif // wxUSE_THREADS
-
-        //
-        // Process the message
-        //
-        DoMessage((WXMSG *)&svCurrentMsg);
-    }
-    return TRUE;
-} // end of wxApp::DoMessage
-
-void wxApp::DoMessage(
-  WXMSG*                            pMsg
-)
-{
-    if (!ProcessMessage((WXMSG *)&svCurrentMsg))
-    {
-        ::WinDispatchMsg(vHabmain, (PQMSG)&svCurrentMsg);
-    }
-} // end of wxApp::DoMessage
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Keep trying to process messages until WM_QUIT
-// received.
-//
-// If there are messages to be processed, they will all be
-// processed and OnIdle will not be called.
-// When there are no more messages, OnIdle is called.
-// If OnIdle requests more time,
-// it will be repeatedly called so long as there are no pending messages.
-// A 'feature' of this is that once OnIdle has decided that no more processing
-// is required, then it won't get processing time until further messages
-// are processed (it'll sit in DoMessage).
-//
-//////////////////////////////////////////////////////////////////////////////
-int wxApp::MainLoop()
-{
-    m_bKeepGoing = TRUE;
-
-    while (m_bKeepGoing)
-    {
-#if wxUSE_THREADS
-        wxMutexGuiLeaveOrEnter();
-#endif // wxUSE_THREADS
-        while (!Pending() && ProcessIdle())
-        {
-            HandleSockets();
-            wxUsleep(10);
-        }
-        HandleSockets();
-        if (Pending())
-            DoMessage();
-        else
-            wxUsleep(10);
-
-    }
-    return (int)svCurrentMsg.mp1;
-} // end of wxApp::MainLoop
-
-void wxApp::ExitMainLoop()
-{
-    ::WinPostMsg(NULL, WM_QUIT, 0, 0);
-} // end of wxApp::ExitMainLoop
-
-bool wxApp::Pending()
-{
-    return (::WinPeekMsg(vHabmain, (PQMSG)&svCurrentMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) != 0);
-} // end of wxApp::Pending
-
-bool wxApp::Dispatch()
-{
-    return DoMessage();
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// 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;
-
-    //
-    // Pass non-system timer messages to the wxTimerProc
-    //
-    if (pMsg->msg == WM_TIMER &&
-        (SHORT1FROMMP(pMsg->mp1) != TID_CURSOR &&
-         SHORT1FROMMP(pMsg->mp1) != TID_FLASHWINDOW &&
-         SHORT1FROMMP(pMsg->mp1) != TID_SCROLL &&
-         SHORT1FROMMP(pMsg->mp1) != 0x0000
-        ))
-        wxTimerProc(NULL, 0, (int)pMsg->mp1, 0);
-
-    //
-    // Allow the window to prevent certain messages from being
-    // translated/processed (this is currently used by wxTextCtrl to always
-    // grab Ctrl-C/V/X, even if they are also accelerators in some parent)
-    //
-    if (pWndThis && !pWndThis->OS2ShouldPreProcessMessage(pWxmsg))
-    {
-        return FALSE;
-    }
-
-    //
-    // 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
-
-bool                                gbInOnIdle = FALSE;
-
-void wxApp::OnIdle(
-  wxIdleEvent&                      rEvent
-)
+void wxApp::OnIdle( wxIdleEvent& WXUNUSED(rEvent) )
 {
-
     //
     // Avoid recursion (via ProcessEvent default case)
     //
     if (gbInOnIdle)
         return;
 
-    gbInOnIdle = TRUE;
-    
-    wxAppBase::OnIdle(rEvent);
+    gbInOnIdle = true;
 
 #if wxUSE_DC_CACHEING
     // automated DC cache management: clear the cached DCs and bitmap
@@ -776,58 +481,46 @@ void wxApp::OnIdle(
         wxDC::ClearCache();
 #endif // wxUSE_DC_CACHEING
 
-    gbInOnIdle = FALSE;
+    gbInOnIdle = false;
 } // end of wxApp::OnIdle
 
 void wxApp::OnEndSession(
   wxCloseEvent&                     WXUNUSED(rEvent))
 {
     if (GetTopWindow())
-        GetTopWindow()->Close(TRUE);
+        GetTopWindow()->Close(true);
 } // end of wxApp::OnEndSession
 
 //
 // Default behaviour: close the application with prompts. The
 // user can veto the close, and therefore the end session.
 //
-void wxApp::OnQueryEndSession(
-  wxCloseEvent&                     rEvent
-)
+void wxApp::OnQueryEndSession( wxCloseEvent& rEvent )
 {
     if (GetTopWindow())
     {
         if (!GetTopWindow()->Close(!rEvent.CanVeto()))
-            rEvent.Veto(TRUE);
+            rEvent.Veto(true);
     }
 } // end of wxApp::OnQueryEndSession
 
-void wxApp::Exit()
-{
-    wxApp::CleanUp();
-
-    // VZ: must really exit somehow, insert appropriate OS/2 syscall (FIXME)
-    wxAppConsole::Exit();
-} // end of wxExit
-
 //
 // Yield to incoming messages
 //
 bool wxApp::Yield(bool onlyIfNeeded)
 {
-    static bool s_inYield = FALSE;
-
-    if ( s_inYield )
+    if ( m_isInsideYield )
     {
         if ( !onlyIfNeeded )
         {
             wxFAIL_MSG( _T("wxYield() called recursively") );
         }
 
-        return FALSE;
+        return false;
     }
 
-    HAB                             vHab = 0;
-    QMSG                            vMsg;
+    HAB vHab = 0;
+    QMSG vMsg;
 
     //
     // Disable log flushing from here because a call to wxYield() shouldn't
@@ -835,20 +528,22 @@ bool wxApp::Yield(bool onlyIfNeeded)
     //
     wxLog::Suspend();
 
-    s_inYield = TRUE;
+    m_isInsideYield = true;
 
     //
     // We want to go back to the main message loop
     // if we see a WM_QUIT. (?)
     //
+    wxEventLoopGuarantor dummyLoopIfNeeded;
     while (::WinPeekMsg(vHab, &vMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && vMsg.msg != WM_QUIT)
     {
 #if wxUSE_THREADS
         wxMutexGuiLeaveOrEnter();
 #endif // wxUSE_THREADS
-        if (!wxTheApp->DoMessage())
+        if (!wxTheApp->Dispatch())
             break;
     }
+
     //
     // If they are pending events, we must process them.
     //
@@ -856,12 +551,14 @@ bool wxApp::Yield(bool onlyIfNeeded)
         wxTheApp->ProcessPendingEvents();
 
     HandleSockets();
+
     //
     // Let the logs be flashed again
     //
     wxLog::Resume();
-    s_inYield = FALSE;
-    return TRUE;
+    m_isInsideYield = false;
+
+    return true;
 } // end of wxYield
 
 int wxApp::AddSocketHandler(int handle, int mask,
@@ -933,7 +630,7 @@ void wxApp::WakeUpIdle()
             //
             // Should never happen
             //
-            wxLogLastError("PostMessage(WM_NULL)");
+            wxLogLastError(wxT("PostMessage(WM_NULL)"));
         }
     }
 } // end of wxWakeUpIdle
@@ -943,10 +640,7 @@ HAB wxGetInstance()
     return vHabmain;
 }
 
-void wxSetInstance(
-  HAB                               vHab
-)
+void wxSetInstance( HAB vHab )
 {
     vHabmain = vHab;
 }
-