• Advertisement
Sign in to follow this  

wxhtml MyApp::OnInit()

This topic is 1522 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

 this is for execution at application start. Now how should I rewrite it to call it as function?

 

 

// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
public:
    // override base class virtuals
    // ----------------------------

    // this one is called on application startup and is a good place for the app
    // initialization (doing it here and not in the ctor allows to have an error
    // return: if OnInit() returns false, the application terminates)
    virtual bool OnInit();

...

...

 

 

// `Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{

...

 

I want to call OnInit from a function and not at app start. If I simply try that I get:

 cannot call member function ‘virtual bool MyApp::OnInit()’ without object

 

Many thanks

 

 

Share this post


Link to post
Share on other sites
Advertisement

You need to instantiate a "MyApp" object in order to call method functions:

int main()
{
    MyApp theApp;
    theApp.OnInit(); // <-- like this

    return 0;
}

But since you're deriving your app from WxApp, I'm going to assume the function OnInit is called automatically for you, so it's a bad idea to call it yourself. That's the whole idea of deriving from a base App class, so the library you're using has control over when to execute what in your program.

 

What are you trying to do?

Share this post


Link to post
Share on other sites

Hmm seems I cannot open a window. Would you have an idea on how to integrate in my existing c++/opengl app without a new window the attached?

[attachment=18848:zip.cpp.zip]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement