[wxWidget2.6.3, Debian testing,
G++ 4.2.1] Hello World with Segment Fault Problem
hpeter
hpeter at gmail.com
Fri Oct 19 19:46:53 PDT 2007
Hello Everybody:
I'm a wxWidget newbie, when I follow the tutorial in the wxwidget
website and i got a segment fault when i close the window, I'm using
Debian testing, wxWidget ver is 2.6.3.2.1.5(Debian testing package),
the following is the code:
wxTestApp.h
==========================
#include "wx/wx.h"
#include "wxTestFrame.h"
#ifndef _WXTEST_APP_H
#define _WXTEST_APP_H
class wxTestApp : public wxApp
{
virtual bool OnInit();
};
//IMPLEMENT_APP_NO_MAIN(wxTestApp)
IMPLEMENT_APP(wxTestApp)
#endif
==========================
wxTestApp.cpp
==========================
#include "wxTestApp.h"
bool wxTestApp::OnInit()
{
wxTestFrame *frame = new wxTestFrame(_T("Hello World"),
wxPoint(50,50), wxSize(450,340) );
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
==========================
wxTestFrame.h
==========================
#include "wx/wx.h"
#ifndef _WXTEST_FRAME_H
#define _WXTEST_FRAME_H
class wxTestFrame: public wxFrame
{
public:
wxTestFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
#endif
==========================
wxTestFrame.cpp
==========================
#include "wxTestFrame.h"
typedef enum
{
wxID_QUIT = 0,
};
BEGIN_EVENT_TABLE(wxTestFrame, wxFrame)
EVT_MENU(wxID_QUIT, wxTestFrame::OnQuit)
END_EVENT_TABLE()
wxTestFrame::wxTestFrame(const wxString& title, const wxPoint& pos,
const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
wxMenu *menuFile = new wxMenu;
menuFile->AppendSeparator();
menuFile->Append( wxID_QUIT, _T("E&xit") );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, _T("&File") );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( _T("Welcome to wxWidgets!") );
}
void wxTestFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
==========================
More information about the wx-users
mailing list