Author Topic: Help setting up wxWidgets  (Read 18671 times)

apo

  • Guest
Re: Help setting up wxWidgets
« Reply #15 on: July 05, 2018, 09:44:59 am »
This thread is ancient (13+ years old), but here is a fix for you anyway:

Change:

class HelloWorldApp : wxApp

into

class HelloWorldApp : public wxApp

and you are good to go.

Hello everyone.

I'm trying to learn how to use wxWidgets using www.3dbuzz.com C++ Video training. They show you how to install wxwidgets, and what you need to do before using it. The thing is, they use Visual Studio, not Code::Blocks, and I can't exactly follow along the setup.

At some point in time, they go to "Project Properties->C/C++->Preprocesor" and then add:
wxUSE_GUI=1; _WXDEBUG_; WXDEBUG=1

And I can't find "preprocesor" anywhere on codeblocks :)

I tried going along, but... let me show you my code.

Code
#include "wx/wx.h"

class HelloWorldApp : wxApp
{
public:
    virtual bool OnInit();
};

IMPLEMENT_APP(HelloWorldApp)

bool HelloWorldApp::OnInit()
{
    wxFrame *frame = new wxFrame((wxFrame *) NULL, -1, _T("Hello World!"), wxPoint(60,70), wxSize(500,600));
   
    frame->Show(TRUE);

    SetTopWindow(frame);
   
    return true;
}

if I try to compile it, it gives me this error:
'wxAppConsole is an inaccessible base of HelloWorldApp', and it says it's on the
IMPLEMENT_APP(HelloWorldApp) line, so I imagine it has something to do with the preprocesor. I don't know, though.

Can someone help me?

Thanks!!