Click here to Skip to main content
15,902,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a small question for wxwidgets, see inside source:

#include "wx/wx.h"
class MyApp : public wxApp
{
    public:
    virtual bool OnInit();
};

class MyFrame : public wxFrame
{
    public:
    MyFrame(const wxString & title);
    void OnQuit(wxCommandEvent & event);
    void OnAbout(wxCommandEvent & event);
    private :
    DECLARE_EVENT_TABLE()
};

DECLARE_APP(MyApp)
IMPLIMENT_APP(MyApp)

bool MyApp::OnInit()//the proplem in here, after it complied that result is:
                    //error: expected constructor, destructor, 
                    //or type conversion  before "bool"

{
    MyFrame *frame = new MyFrame(wxT("Minimal wxWidget App"));
    frame->Show(true);
    return true;
}

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
    EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
END_EVENT_TABLE()

void MyFrame::OnAbout(wxCommandEvent & event)
{
    wxString msg;
    msg.Printf(wxT("Hello and Welcome to %s"),
                wxVERSION_STRING);

    wxMessageBox(msg, wxT("About Minimal"),
                    wxOK|wxICON_INFORMATION,this);
}

void MyFrame::OnQuit(wxCommandEvent & event)
{
    Close();
}

#include "mondrian.xpm"

MyFrame::MyFrame(const wxString & title)
    :wxFrame(NULL, wxID_ANY, title)
{
    SetIcon(wxIcon(mondrian_xpm));

    wxMenu *fileMenu = new wxMenu;
    wxMenu *helpMenu = new wxMenu;
    helpMenu->Append(wxID_ABOUT, wxT("&About...\tF1"),
                        wxT("Show about dailog"));
    fileMenu->Append(wxID_EXIT, wxT("E&xit\tAlt-X"),
                        wxT("Quit this program"));

    wxMenuBar * MenuBar = new wxMenuBar();
    MenuBar->Append(fileMenu, wxT("&File"));
    MenuBar->Append(helpMenu, wxT("&Help"));

    SetMenuBar(MenuBar);

    CreateStatusBar(2);
    SetStatusText(wxT("Welcome to wxWidgets!"));
}
Posted
Updated 20-Jun-10 22:02pm
v2

Louis Cooper wrote:
IMPLIMENT_APP(MyApp)


Should be IMPLEMENT_APP(MyApp)
 
Share this answer
 
:-D Ar!! Yes, That's it! thank you very much:thumbsup:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900