#pragma hdrstop
#endif
-#ifndef WX_PRECOMP
#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
#include "mfctest.h"
-#include "wx/wx.h"
-
/////////////////////////////////////////////////////////////////////////////
// theApp:
wxFrame *CreateFrame(void);
};
-DECLARE_APP(MyApp)
-
class MyCanvas: public wxScrolledWindow
{
public:
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);
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
int CTheApp::ExitInstance()
{
+ // OnExit isn't called by CleanUp so must be called explicitly.
+ wxTheApp->OnExit();
wxApp::CleanUp();
return CWinApp::ExitInstance();
// 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 *MyApp::CreateFrame(void)
{
MyChild *subframe = new MyChild(NULL, "Canvas Frame", wxPoint(10, 10), wxSize(300, 300),
- wxDEFAULT_FRAME);
+ wxDEFAULT_FRAME_STYLE);
subframe->SetTitle("wxWindows canvas frame");
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
{
wxPaintDC dc(this);
- dc.SetFont(small_font);
- dc.SetPen(wxGREEN_PEN);
+ dc.SetFont(* wxSWISS_FONT);
+ dc.SetPen(* wxGREEN_PEN);
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
- dc.SetBrush(wxCYAN_BRUSH);
- dc.SetPen(wxRED_PEN);
+ dc.SetBrush(* wxCYAN_BRUSH);
+ dc.SetPen(* wxRED_PEN);
dc.DrawRectangle(100, 100, 100, 50);
dc.DrawRoundedRectangle(150, 150, 100, 50, 20);
void MyCanvas::OnMouseEvent(wxMouseEvent& event)
{
wxClientDC dc(this);
- dc.SetPen(wxBLACK_PEN);
+ dc.SetPen(* wxBLACK_PEN);
long x, y;
event.Position(&x, &y);
if (xpos > -1 && ypos > -1 && event.Dragging())
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()