]> git.saurik.com Git - wxWidgets.git/commitdiff
Further changes to make mfctest work.
authorJulian Smart <julian@anthemion.co.uk>
Thu, 4 Feb 1999 22:06:15 +0000 (22:06 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 4 Feb 1999 22:06:15 +0000 (22:06 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1601 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/mfc/mfctest.cpp
src/msw/app.cpp

index 26e03e26fb1d0690da7a8188a79df7036bc57fb7..740bfbbbc1585c1c434a1b17b18807ef80b684d7 100644 (file)
@@ -74,8 +74,6 @@ class MyApp: public wxApp
     wxFrame *CreateFrame(void);
  };
 
     wxFrame *CreateFrame(void);
  };
 
-DECLARE_APP(MyApp)
-
 class MyCanvas: public wxScrolledWindow
 {
   public:
 class MyCanvas: public wxScrolledWindow
 {
   public:
@@ -104,10 +102,6 @@ DECLARE_EVENT_TABLE()
 long xpos = -1;
 long ypos = -1;
 
 long xpos = -1;
 long ypos = -1;
 
-// Initialise this in OnInit, not statically
-wxPen *red_pen;
-wxFont *small_font;
-
 // ID for the menu quit command
 #define HELLO_QUIT 1
 #define HELLO_NEW  2
 // ID for the menu quit command
 #define HELLO_QUIT 1
 #define HELLO_NEW  2
@@ -219,6 +213,8 @@ BOOL CTheApp::InitInstance()
 
 int CTheApp::ExitInstance()
 {
 
 int CTheApp::ExitInstance()
 {
+  // OnExit isn't called by CleanUp so must be called explicitly.
+  wxTheApp->OnExit();
   wxApp::CleanUp();
 
   return CWinApp::ExitInstance();
   wxApp::CleanUp();
 
   return CWinApp::ExitInstance();
@@ -252,12 +248,6 @@ bool MyApp::OnInit(void)
   // Don't exit app when the top level frame is deleted
 //  SetExitOnFrameDelete(FALSE);
   
   // Don't exit app when the top level frame is deleted
 //  SetExitOnFrameDelete(FALSE);
   
-  // Create a red pen
-  red_pen = new wxPen("RED", 3, wxSOLID);
-
-  // Create a small font
-  small_font = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
-
   wxFrame* frame = CreateFrame();
   return TRUE;
 }
   wxFrame* frame = CreateFrame();
   return TRUE;
 }
@@ -289,8 +279,7 @@ wxFrame *MyApp::CreateFrame(void)
       subframe->GetClientSize(&width, &height);
 
       MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));
       subframe->GetClientSize(&width, &height);
 
       MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));
-      wxCursor *cursor = new wxCursor(wxCURSOR_PENCIL);
-      canvas->SetCursor(*cursor);
+      canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
       subframe->canvas = canvas;
 
       // Give it scrollbars
       subframe->canvas = canvas;
 
       // Give it scrollbars
@@ -317,7 +306,7 @@ void MyCanvas::OnPaint(wxPaintEvent& event)
 {
     wxPaintDC dc(this);
 
 {
     wxPaintDC dc(this);
 
-    dc.SetFont(* small_font);
+    dc.SetFont(* wxSWISS_FONT);
     dc.SetPen(* wxGREEN_PEN);
     dc.DrawLine(0, 0, 200, 200);
     dc.DrawLine(200, 0, 0, 200);
     dc.SetPen(* wxGREEN_PEN);
     dc.DrawLine(0, 0, 200, 200);
     dc.DrawLine(200, 0, 0, 200);
index a3301a60857d6de7b33fa4ad242462f4b2358947..cbf871abdea2d4b3cc73d757ef4750e6d0802ece 100644 (file)
@@ -445,6 +445,15 @@ void wxApp::ConvertToStandardCommandArgs(char* lpCmdLine)
 void wxApp::CleanUp()
 {
   //// COMMON CLEANUP
 void wxApp::CleanUp()
 {
   //// COMMON CLEANUP
+
+  // flush the logged messages if any
+  wxLog *pLog = wxLog::GetActiveTarget();
+  if ( pLog != NULL && pLog->HasPendingMessages() )
+    pLog->Flush();
+
+  // One last chance for pending objects to be cleaned up
+  wxTheApp->DeletePendingObjects();
+
   wxModule::CleanUpModules();
 
 #if wxUSE_WX_RESOURCES
   wxModule::CleanUpModules();
 
 #if wxUSE_WX_RESOURCES
@@ -608,6 +617,9 @@ int wxEntry(WXHINSTANCE hInstance,
       {
           retValue = wxTheApp->OnRun();
       }
       {
           retValue = wxTheApp->OnRun();
       }
+      else
+        // We want to initialize, but not run or exit immediately.
+        return 1;
   }
   //else: app initialization failed, so we skipped OnRun()
 
   }
   //else: app initialization failed, so we skipped OnRun()
 
@@ -630,12 +642,6 @@ int wxEntry(WXHINSTANCE hInstance,
 
   wxTheApp->OnExit();
 
 
   wxTheApp->OnExit();
 
-  // flush the logged messages if any
-  wxLog *pLog = wxLog::GetActiveTarget();
-  if ( pLog != NULL && pLog->HasPendingMessages() )
-    pLog->Flush();
-
-
   wxApp::CleanUp();
 
   return retValue;
   wxApp::CleanUp();
 
   return retValue;