X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17b74d79adcc7bbd5cff4ed500e267289c0083a7..302aa842e96914fb11dd86972c3e6d79f35bc44d:/samples/mfc/mfctest.cpp diff --git a/samples/mfc/mfctest.cpp b/samples/mfc/mfctest.cpp index 26e03e26fb..91ed30dbdc 100644 --- a/samples/mfc/mfctest.cpp +++ b/samples/mfc/mfctest.cpp @@ -44,6 +44,10 @@ #include "wx/wx.h" +#ifdef _WINDOWS_ +#error Sorry, you need to edit include/wx/wxprec.h, comment out the windows.h inclusion, and recompile. +#endif + #ifdef new #undef new #endif @@ -74,8 +78,6 @@ class MyApp: public wxApp wxFrame *CreateFrame(void); }; -DECLARE_APP(MyApp) - class MyCanvas: public wxScrolledWindow { public: @@ -91,7 +93,6 @@ class MyChild: public wxFrame MyCanvas *canvas; MyChild(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); ~MyChild(void); - bool OnClose(void); void OnQuit(wxCommandEvent& event); void OnNew(wxCommandEvent& event); @@ -104,10 +105,6 @@ DECLARE_EVENT_TABLE() 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 @@ -219,6 +216,8 @@ BOOL CTheApp::InitInstance() int CTheApp::ExitInstance() { + // OnExit isn't called by CleanUp so must be called explicitly. + wxTheApp->OnExit(); wxApp::CleanUp(); return CWinApp::ExitInstance(); @@ -252,12 +251,6 @@ bool MyApp::OnInit(void) // 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; } @@ -289,8 +282,7 @@ wxFrame *MyApp::CreateFrame(void) 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 @@ -317,7 +309,7 @@ void MyCanvas::OnPaint(wxPaintEvent& event) { 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); @@ -383,12 +375,6 @@ void MyChild::OnActivate(wxActivateEvent& event) canvas->SetFocus(); } -bool MyChild::OnClose(void) -{ - return TRUE; -} - - // Dummy MFC window for specifying a valid main window to MFC, using // a wxWindows HWND. CDummyWindow::CDummyWindow(HWND hWnd):CWnd()