Jump to content

  • Log In with Google      Sign In   
  • Create Account


wxhtml MyApp::OnInit()


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 FGFS   Members   -  Reputation: 193

Like
0Likes
Like

Posted 20 November 2013 - 08:36 AM

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

 

 



Sponsor:

#2 TheComet   Members   -  Reputation: 1479

Like
1Likes
Like

Posted 20 November 2013 - 08:58 AM

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?


YOUR_OPINION >/dev/null


#3 FGFS   Members   -  Reputation: 193

Like
0Likes
Like

Posted 21 November 2013 - 01:45 AM

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?

Attached File  zip.cpp.zip   2.01KB   9 downloads






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS