wxWidgets Beispielapplikation Parameter 0L
-
Guten Tag,
bei der wxWidgets Beispielapplikation von Code::Blocks wird dem Konstruktor von Frame der Parameter 0L übergeben. Kann mir jemand diesen Parameter erklären? Denn der eigentliche Konstruktur erwartet viele Parameter und nicht nur einen. Hier nochmal die Beispielapplikation:
//File: MyApp.h #ifndef MYAPP_H #define MYAPP_H #include <wx/app.h> class MyApp : public wxApp { public: virtual bool OnInit(); }; #endif // MYAPP_H
//File: MyApp.cpp #ifdef WX_PRECOMP #include "wx_pch.h" #endif #ifdef __BORLANDC__ #pragma hdrstop #endif //__BORLANDC__ #include "MyApp.h" #include "MyMain.h" IMPLEMENT_APP(MyApp); bool MyApp::OnInit() { MyFrame* frame = new MyFrame(0L); frame->SetIcon(wxICON(aaaa)); // To Set App Icon frame->Show(); return true; }
//File: GUIFrame.h /////////////////////////////////////////////////////////////////////////// // C++ code generated with wxFormBuilder (version Feb 17 2007) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __GUIFrame__ #define __GUIFrame__ // Define WX_GCH in order to support precompiled headers with GCC compiler. // You have to create the header "wx_pch.h" and include all files needed // for compile your gui inside it. // Then, compile it and place the file "wx_pch.h.gch" into the same // directory that "wx_pch.h". #ifdef WX_GCH #include <wx_pch.h> #else #include <wx/wx.h> #endif #include <wx/menu.h> /////////////////////////////////////////////////////////////////////////// #define idMenuQuit 1000 #define idMenuAbout 1001 /////////////////////////////////////////////////////////////////////////////// /// Class GUIFrame /////////////////////////////////////////////////////////////////////////////// class GUIFrame : public wxFrame { DECLARE_EVENT_TABLE() private: // Private event handlers void _wxFB_OnClose( wxCloseEvent& event ){ OnClose( event ); } void _wxFB_OnQuit( wxCommandEvent& event ){ OnQuit( event ); } void _wxFB_OnAbout( wxCommandEvent& event ){ OnAbout( event ); } protected: wxMenuBar* mbar; wxStatusBar* statusBar; // Virtual event handlers, overide them in your derived class virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } virtual void OnQuit( wxCommandEvent& event ){ event.Skip(); } virtual void OnAbout( wxCommandEvent& event ){ event.Skip(); } public: GUIFrame( wxWindow* parent, int id = wxID_ANY, wxString title = wxT("wxWidgets Application Template"), wxPoint pos = wxDefaultPosition, wxSize size = wxSize( 481,466 ), int style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); }; #endif //__GUIFrame__
//File: GUIFrame.cpp /////////////////////////////////////////////////////////////////////////// // C++ code generated with wxFormBuilder (version Feb 17 2007) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif //__BORLANDC__ #ifndef WX_PRECOMP #include <wx/wx.h> #endif //WX_PRECOMP #include "GUIFrame.h" /////////////////////////////////////////////////////////////////////////// BEGIN_EVENT_TABLE( GUIFrame, wxFrame ) EVT_CLOSE( GUIFrame::_wxFB_OnClose ) EVT_MENU( idMenuQuit, GUIFrame::_wxFB_OnQuit ) EVT_MENU( idMenuAbout, GUIFrame::_wxFB_OnAbout ) END_EVENT_TABLE() GUIFrame::GUIFrame( wxWindow* parent, int id, wxString title, wxPoint pos, wxSize size, int style ) : wxFrame( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); mbar = new wxMenuBar( 0 ); wxMenu* fileMenu; fileMenu = new wxMenu(); wxMenuItem* menuFileQuit = new wxMenuItem( fileMenu, idMenuQuit, wxString( wxT("&Quit") ) + wxT('\t') + wxT("Alt+F4"), wxT("Quit the application"), wxITEM_NORMAL ); fileMenu->Append( menuFileQuit ); mbar->Append( fileMenu, wxT("&File") ); wxMenu* helpMenu; helpMenu = new wxMenu(); wxMenuItem* menuHelpAbout = new wxMenuItem( helpMenu, idMenuAbout, wxString( wxT("&About") ) + wxT('\t') + wxT("F1"), wxT("Show info about this application"), wxITEM_NORMAL ); helpMenu->Append( menuHelpAbout ); mbar->Append( helpMenu, wxT("&Help") ); this->SetMenuBar( mbar ); statusBar = this->CreateStatusBar( 2, wxST_SIZEGRIP, wxID_ANY ); }
//File: MyMain.h #ifndef MYMAIN_H #define MYMAIN_H #include "MyApp.h" #include "GUIFrame.h" class MyFrame: public GUIFrame { public: MyFrame(wxFrame *frame); ~MyFrame(); private: virtual void OnClose(wxCloseEvent& event); virtual void OnQuit(wxCommandEvent& event); virtual void OnAbout(wxCommandEvent& event); }; #endif // MYMAIN_H
//File: MyMain.cpp #ifdef WX_PRECOMP #include "wx_pch.h" #endif #ifdef __BORLANDC__ #pragma hdrstop #endif //__BORLANDC__ #include "MyMain.h" //helper functions enum wxbuildinfoformat { short_f, long_f }; wxString wxbuildinfo(wxbuildinfoformat format) { wxString wxbuild(wxVERSION_STRING); if (format == long_f ) { #if defined(__WXMSW__) wxbuild << _T("-Windows"); #elif defined(__WXMAC__) wxbuild << _T("-Mac"); #elif defined(__UNIX__) wxbuild << _T("-Linux"); #endif #if wxUSE_UNICODE wxbuild << _T("-Unicode build"); #else wxbuild << _T("-ANSI build"); #endif // wxUSE_UNICODE } return wxbuild; } MyFrame::MyFrame(wxFrame *frame) : GUIFrame(frame) { #if wxUSE_STATUSBAR statusBar->SetStatusText(_("Hello Code::Blocks user!"), 0); statusBar->SetStatusText(wxbuildinfo(short_f), 1); #endif } MyFrame::~MyFrame() { } void MyFrame::OnClose(wxCloseEvent &event) { Destroy(); } void MyFrame::OnQuit(wxCommandEvent &event) { Destroy(); } void MyFrame::OnAbout(wxCommandEvent &event) { wxString msg = wxbuildinfo(long_f); wxMessageBox(msg, _("Welcome to...")); }
Mit freundlichen Grüßen,
DarkBug
-
*push*
-
0L == NULL == Nullzeiger. Bedeutet, dass das Fenster keinen Parent hat. Für die anderen Parameter werden Defaultparameter genommen.
-
Achso! Danke für die Hilfe.