]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/app.cpp
More compilation fixes.
[wxWidgets.git] / src / os2 / app.cpp
index 521f05f5868b7866bc55bc28d2d586072d859a7d..737de733cfca887bff142a9fa0f1d8a4bbdb5b78 100644 (file)
@@ -92,11 +92,11 @@ HICON wxDEFAULT_MDIPARENTFRAME_ICON  = (HICON) NULL;
 
 HBRUSH wxDisableButtonBrush = (HBRUSH) 0;
 
-MRESULT wxWndProc( HWND
-                  ,ULONG
-                  ,MPARAM
-                  ,MPARAM
-                 );
+MRESULT EXPENTRY wxWndProc( HWND
+                           ,ULONG
+                           ,MPARAM
+                           ,MPARAM
+                          );
 
 // ===========================================================================
 // implementation
@@ -119,6 +119,16 @@ bool wxApp::Initialize(
   HAB                               vHab
 )
 {
+    //
+    // OS2 has to have an anchorblock
+    //
+    vHab = WinInitialize(0);
+
+    if (!vHab)
+        return FALSE;
+    else
+        vHabmain = vHab;
+
     // Some people may wish to use this, but
     // probably it shouldn't be here by default.
 #ifdef __WXDEBUG__
@@ -188,100 +198,110 @@ bool wxApp::RegisterWindowClasses(
 )
 {
     APIRET                          rc;
+    ERRORID                         vError = 0L;
+    wxString                        sError;
 
-    if ((rc = ::WinRegisterClass( vHab
-                                 ,wxFrameClassName
-                                 ,(PFNWP)wxWndProc
-                                 ,CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST | CS_CLIPCHILDREN | CS_FRAME
-                                 ,0
-                                )) != 0)
+    if (!::WinRegisterClass( vHab
+                            ,wxFrameClassName
+                            ,(PFNWP)wxWndProc
+                            ,CS_SIZEREDRAW | CS_SYNCPAINT
+                            ,sizeof(ULONG)
+                           ))
     {
-        wxLogLastError("RegisterClass(frame)");
-
+        vError = ::WinGetLastError(vHab);
+        sError = wxPMErrorToStr(vError);
+        wxLogLastError(sError);
         return FALSE;
     }
 
     if (!::WinRegisterClass( vHab
                             ,wxFrameClassNameNoRedraw
                             ,(PFNWP)wxWndProc
-                            ,CS_HITTEST | CS_CLIPCHILDREN | CS_FRAME
+                            ,0
                             ,0
                            ))
     {
-        wxLogLastError("RegisterClass(no redraw frame)");
-
+        vError = ::WinGetLastError(vHab);
+        sError = wxPMErrorToStr(vError);
+        wxLogLastError(sError);
         return FALSE;
     }
 
     if (!::WinRegisterClass( vHab
                             ,wxMDIFrameClassName
                             ,(PFNWP)wxWndProc
-                            ,CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST | CS_CLIPCHILDREN | CS_FRAME
+                            ,CS_SIZEREDRAW | CS_SYNCPAINT
                             ,0
                            ))
     {
-        wxLogLastError("RegisterClass(MDI parent)");
-
+        vError = ::WinGetLastError(vHab);
+        sError = wxPMErrorToStr(vError);
+        wxLogLastError(sError);
         return FALSE;
     }
 
     if (!::WinRegisterClass( vHab
                             ,wxMDIFrameClassNameNoRedraw
                             ,(PFNWP)wxWndProc
-                            ,CS_HITTEST | CS_CLIPCHILDREN | CS_FRAME
+                            ,0
                             ,0
                            ))
     {
-        wxLogLastError("RegisterClass(no redraw MDI parent)");
-
+        vError = ::WinGetLastError(vHab);
+        sError = wxPMErrorToStr(vError);
+        wxLogLastError(sError);
         return FALSE;
     }
 
     if (!::WinRegisterClass( vHab
                             ,wxMDIChildFrameClassName
                             ,(PFNWP)wxWndProc
-                            ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST | CS_CLIPSIBLINGS | CS_FRAME
+                            ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST
                             ,0
                            ))
     {
-        wxLogLastError("RegisterClass(MDI child)");
-
+        vError = ::WinGetLastError(vHab);
+        sError = wxPMErrorToStr(vError);
+        wxLogLastError(sError);
         return FALSE;
     }
 
     if (!::WinRegisterClass( vHab
                             ,wxMDIChildFrameClassNameNoRedraw
                             ,(PFNWP)wxWndProc
-                            ,CS_HITTEST | CS_CLIPSIBLINGS | CS_FRAME
+                            ,CS_HITTEST
                             ,0
                            ))
     {
-        wxLogLastError("RegisterClass(no redraw MDI child)");
-
+        vError = ::WinGetLastError(vHab);
+        sError = wxPMErrorToStr(vError);
+        wxLogLastError(sError);
         return FALSE;
     }
 
     if (!::WinRegisterClass( vHab
                             ,wxPanelClassName
                             ,(PFNWP)wxWndProc
-                            ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_CLIPSIBLINGS | CS_SAVEBITS | CS_SYNCPAINT
+                            ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT
                             ,0
                            ))
     {
-        wxLogLastError("RegisterClass(Panel)");
-
+        vError = ::WinGetLastError(vHab);
+        sError = wxPMErrorToStr(vError);
+        wxLogLastError(sError);
         return FALSE;
     }
 
     if (!::WinRegisterClass( vHab
                             ,wxCanvasClassName
                             ,(PFNWP)wxWndProc
-                            ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_CLIPSIBLINGS | CS_SAVEBITS | CS_SYNCPAINT
+                            ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT
                             ,0
                            ))
     {
-        wxLogLastError("RegisterClass(Canvas)");
-
+        vError = ::WinGetLastError(vHab);
+        sError = wxPMErrorToStr(vError);
+        wxLogLastError(sError);
         return FALSE;
     }
     return TRUE;
@@ -335,7 +355,7 @@ void wxApp::CleanUp()
     delete[] wxBuffer;
     wxBuffer = NULL;
 
-    //// WINDOWS-SPECIFIC CLEANUP
+    //// PM-SPECIFIC CLEANUP
 
     // wxSetKeyboardHook(FALSE);
 
@@ -410,17 +430,14 @@ int wxEntry(
     //
     if (!wxTheApp)
     {
-        wxCHECK_MSG( wxApp::GetInitializerFunction()
-                    ,-1
-                    ,wxT("wxWindows error: No initializer - use IMPLEMENT_APP macro.\n")
-                   );
-
-        wxAppInitializerFunction    fnAppIni = wxApp::GetInitializerFunction();
-        wxObject*                   pTest_app = fnAppIni();
-
-        wxTheApp = (wxApp*)pTest_app;
+        // The app may have declared a global application object, but we recommend
+        // the IMPLEMENT_APP macro is used instead, which sets an initializer
+        // function for delayed, dynamic app object construction.
+        wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
+                     wxT("No initializer - use IMPLEMENT_APP macro.") );
+        wxTheApp = (*wxApp::GetInitializerFunction()) ();
     }
-    wxCHECK_MSG( wxTheApp, -1, wxT("wxWindows error: no application object") );
+    wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
     wxTheApp->argc = argc;
 
 #if wxUSE_UNICODE
@@ -452,28 +469,26 @@ int wxEntry(
     {
         if (wxTheApp->OnInit())
         {
-            nRetValue = -1;
+            nRetValue = wxTheApp->OnRun();
+//          nRetValue = -1;
         }
     }
 
-    if (nRetValue == 0)
-    {
-        wxWindow*                   pTopWindow = wxTheApp->GetTopWindow();
+    wxWindow*                       pTopWindow = wxTheApp->GetTopWindow();
 
-        if (pTopWindow)
+    if (pTopWindow)
+    {
+        // Forcibly delete the window.
+        if (pTopWindow->IsKindOf(CLASSINFO(wxFrame)) ||
+            pTopWindow->IsKindOf(CLASSINFO(wxDialog)) )
         {
-            // Forcibly delete the window.
-            if (pTopWindow->IsKindOf(CLASSINFO(wxFrame)) ||
-                pTopWindow->IsKindOf(CLASSINFO(wxDialog)) )
-            {
-                pTopWindow->Close(TRUE);
-                wxTheApp->DeletePendingObjects();
-            }
-            else
-            {
-                delete pTopWindow;
-                wxTheApp->SetTopWindow(NULL);
-            }
+            pTopWindow->Close(TRUE);
+            wxTheApp->DeletePendingObjects();
+        }
+        else
+        {
+            delete pTopWindow;
+            wxTheApp->SetTopWindow(NULL);
         }
     }
     wxTheApp->OnExit();
@@ -483,9 +498,17 @@ int wxEntry(
 
 bool wxApp::OnInitGui()
 {
-    vHabmain = WinInitialize(0);
-    m_hMq    = WinCreateMsgQueue(vHabmain, 0);
+    ERRORID                         vError;
+    wxString                        sError;
 
+    m_hMq = ::WinCreateMsgQueue(vHabmain, 0);
+    if (!m_hMq)
+    {
+        vError = ::WinGetLastError(vHabmain);
+        sError = wxPMErrorToStr(vError);
+        wxLogDebug(sError);
+        return FALSE;
+    }
     return TRUE;
 }