wxGetApp() not working Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

wxGetApp() not working

Post by rakeshthp »

Hey,,

Thanks for those links.. actually, i am unaware of those technical terms (like flicker).. anyways, it helped me lot and my problem is solved.. Thanks anyways..

One more small doubt.. I am not able to use wxGetApp() function from any other class, other then MyApp class...

I have declared,

DECLARE_APP(myapp) in the header file (MyApp.h).. still it is not working.. what may be the problem.? I have also included,

#include <wx/app.h>

Thanks and Regards
Rakesh
stevelam
Earned some good credits
Earned some good credits
Posts: 114
Joined: Fri Apr 14, 2006 11:01 am

Post by stevelam »

In your classes you will need to include MyApp.h :)
rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Post by rakeshthp »

You mean to say, in MyApp.cpp or all other classes.??

I have included MyApp.h in MyApp.cpp
stevelam
Earned some good credits
Earned some good credits
Posts: 114
Joined: Fri Apr 14, 2006 11:01 am

Post by stevelam »

In all of the classes that would want to use wxGetApp() from as far as I know.
Ridmix
Knows some wx things
Knows some wx things
Posts: 40
Joined: Sat Dec 01, 2007 9:27 am

Post by Ridmix »

Do you have IMPLEMENT_APP(myapp) in MyApp.cpp?
wxWidgets 2.8.10 & WX_TRUNK
Ubuntu 9.10
GCC 4.4
rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Post by rakeshthp »

ya... implemented in MyApp.cpp....
rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Post by rakeshthp »

On including MyApp.h in all the classes am getting list of errors in each class wher i include it.. any other solution??
protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol »

What are the errors? How are you including it?

You may need to use a forward declaration, in the *.h files then include MyApp.h in the *.cpp files.


regards.
/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!
yakumoklesk
Knows some wx things
Knows some wx things
Posts: 36
Joined: Mon Jan 01, 2007 10:55 am

Post by yakumoklesk »

rakeshthp wrote:On including MyApp.h in all the classes am getting list of errors in each class wher i include it.. any other solution??
does MyApp.h looks like this?

Code: Select all

#ifndef __MYAPP_H__
#define __MYAPP_H__

App class declaration

DECLARE_APP(MyApp)

#endif
Yakumo, searching Pai.
rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Post by rakeshthp »

myapp.h definition looks like this

#include <wx/wx.h>
#include "FrameEX.h"

class ESPL : public wxApp{
public:
FrameEX *m_esplframe;
virtual bool OnInit();
ESPL();
~ESPL();
}

DECLARE_APP(ESPL)

And .cpp file contains

#include "ESPL.h"

IMPLEMENT_APP(ESPL)

ESPL::ESPL(){
// code to initialize
}

ESPL::~ESPL(){
remove("Points"); // removing temp file
}

bool ESPL::OnInit(){
m_esplframe = new FrameEX(NULL,wxID_ANY,wxT("Graphics Application"), wxDefaultPosition, wxDefaultSize);
m_esplframe->Show(true);
}

Thats it.. What else has to be there..?? Any rules are there to make wxGetApp() work..?? Or any situations where wxGetApp() doesnt work??
yakumoklesk
Knows some wx things
Knows some wx things
Posts: 36
Joined: Mon Jan 01, 2007 10:55 am

Post by yakumoklesk »

rakeshthp wrote:myapp.h definition looks like this

#include <wx/wx.h>
#include "FrameEX.h"

class ESPL : public wxApp{
public:
FrameEX *m_esplframe;
virtual bool OnInit();
ESPL();
~ESPL();
}

DECLARE_APP(ESPL)

And .cpp file contains

#include "ESPL.h"

IMPLEMENT_APP(ESPL)

ESPL::ESPL(){
// code to initialize
}

ESPL::~ESPL(){
remove("Points"); // removing temp file
}

bool ESPL::OnInit(){
m_esplframe = new FrameEX(NULL,wxID_ANY,wxT("Graphics Application"), wxDefaultPosition, wxDefaultSize);
m_esplframe->Show(true);
}

Thats it.. What else has to be there..?? Any rules are there to make wxGetApp() work..?? Or any situations where wxGetApp() doesnt work??
Don't take these words as if I want to tell you off, but please, when you post code, use the code tag.

Second of all, get sure all your header files use the "once only header" technique:

http://gcc.gnu.org/onlinedocs/cpp/Once_ ... ly-Headers

More: I don't know how are the constructors of wxApp, but when you derive one class from another, in the derived class you should call the base class constructor.

Code: Select all

ESPL::ESPL()
: wxApp()  // <-- Calls the base constructor
{
   // code to initialize
}

Anyway, for wxApp derived class, I do not recommend creating constructors nor destructors. Just use the OnInit and the OnExit, so your "remove(Points)" will be called in the OnExit method of your ESPL class.

Try first these things and then tell me.
Yakumo, searching Pai.
rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Post by rakeshthp »

ok..

thanks dear.. i'll try them and get back to you... And thanks for guiding me by giving suggestions... it will really help me to develop myself as a professional...

Thanks once again..
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

As far as I can tell it's about ok. Can you post the error message you get when trying to use wxGetApp() from a file that includes myapp.h ?
"Keyboard not detected. Press F1 to continue"
-- Windows
rakeshthp
I live to help wx-kind
I live to help wx-kind
Posts: 154
Joined: Mon Apr 06, 2009 10:02 am
Location: India

Post by rakeshthp »

It throws hundreds of error messages, one set for each classs... :) Undefined class <classname> and all variables also undefined it listss.. :) very strange and funny compiler..
yakumoklesk
Knows some wx things
Knows some wx things
Posts: 36
Joined: Mon Jan 01, 2007 10:55 am

Post by yakumoklesk »

Posting the error means posting the error, not a description of the error.

Please, can you copy paste the output of your compiler? Also could you output the full command line?
Yakumo, searching Pai.
Post Reply