OVERVIEW
We create two windows in the sample program below.
SAMPLE CODE
window1.h
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class Window1: public wxFrame {
public:
Window1(const wxString& title);
};
window1.cpp
#include "window1.h"
Window1::Window1(const wxString& title):
wxFrame(NULL, -1, title, wxDefaultPosition, wxSize(400,200)) {
Center();
}
window2.h
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class Window2: public wxFrame {
public:
Window2(const wxString& title);
};
window2.cpp
#include "window2.h"
Window2::Window2(const wxString& title):
wxFrame(NULL, -1, title, wxPoint(100,10), wxSize(400,200)) {
}
main.h
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
class Main: public wxApp {
public:
virtual bool OnInit();
};
main.cpp
#include "main.h"
#include "window1.h"
#include "window2.h"
IMPLEMENT_APP(Main)
bool Main::OnInit() {
Window1 *win = new Window1(wxT("First Window"));
win->Show(true);
Window2 *win2 = new Window2(wxT("Second Window"));
win2->Show(true);
return TRUE;
}
The output is shown below:
Leave a Reply