Ik wil dus beginnen met het schrijven van programma's met wxWidgets. In het begin gebruikte ik altijd DevC++ maar omdat het compilen hier ZO langzaam ging, heb ik het maar opgegeven. Nu probeer ik het met Visual C++ 2005 Express omdat het een snellere compiler schijnt te zijn. Ik heb wxWidgets gecompiled, en dat liep vrij goed (afgezien van een depreciated warning hier en daar). Toen heb ik alle headers en libs gekopieerd naar VC++'s mappen. Nu probeer ik een simpel programmatje te compilen, maar krijg ik de error
"e:\my documents\visual studio 2005\projects\wxtest\wxtest\wxtest.cpp(46) : error C2664: 'MyFrame::MyFrame(const wxString &,const wxPoint &,const wxSize &)' : cannot convert parameter 1 from 'const char [12]' to 'const wxString &'
Reason: cannot convert from 'const char [12]' to 'const wxString'"
En dit dan paar keer, telkens als ik een string als parameter mee wil zenden.
"e:\my documents\visual studio 2005\projects\wxtest\wxtest\wxtest.cpp(46) : error C2664: 'MyFrame::MyFrame(const wxString &,const wxPoint &,const wxSize &)' : cannot convert parameter 1 from 'const char [12]' to 'const wxString &'
Reason: cannot convert from 'const char [12]' to 'const wxString'"
En dit dan paar keer, telkens als ik een string als parameter mee wil zenden.
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
| #include <wx/wx.h> class MyApp: public wxApp { virtual bool OnInit(); }; class MyFrame: public wxFrame { public: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); DECLARE_EVENT_TABLE() }; enum { ID_Quit = 1, ID_About, }; BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_Quit, MyFrame::OnQuit) EVT_MENU(ID_About, MyFrame::OnAbout) END_EVENT_TABLE() IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { MyFrame *frame = new MyFrame("Hello World", wxPoint(50,50), wxSize(450,340) ); frame->Show(TRUE); SetTopWindow(frame); return TRUE; } MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame((wxFrame *)NULL, -1, title, pos, size) { wxMenu *menuFile = new wxMenu; menuFile->Append( ID_About, "&About..." ); menuFile->AppendSeparator(); menuFile->Append( ID_Quit, "E&xit" ); wxMenuBar *menuBar = new wxMenuBar; menuBar->Append( menuFile, "&File" ); SetMenuBar( menuBar ); CreateStatusBar(); SetStatusText( "Welcome to wxWindows!" ); } void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(TRUE); } void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxMessageBox("This is a wxWindows Hello world sample", "About Hello World", wxOK | wxICON_INFORMATION, this); } |