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 » Thu Jun 11, 2009 8:09 am

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 » Thu Jun 11, 2009 8:21 am

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 » Thu Jun 11, 2009 10:29 am

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 » Thu Jun 11, 2009 10:30 am

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 » Thu Jun 11, 2009 10:42 am

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 » Thu Jun 11, 2009 12:12 pm

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 » Fri Jun 12, 2009 4:35 am

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 » Fri Jun 12, 2009 5:16 am

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 » Fri Jun 12, 2009 5:46 pm

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 » Sat Jun 13, 2009 1:04 pm

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 » Sat Jun 13, 2009 1:18 pm

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 » Sat Jun 13, 2009 1:25 pm

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 » Sat Jun 13, 2009 2:16 pm

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 » Mon Jun 15, 2009 5:00 am

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 » Mon Jun 15, 2009 6:07 am

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