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.
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

yakumoklesk wrote: Please, can you copy paste the output of your compiler? Also could you output the full command line?
What he said :roll:

Don't take this bad, but reading this may help you get helped : http://www.catb.org/~esr/faqs/smart-questions.html

We need to know what the compiler says, not what you think the compiler says. By definition, if you're trying to get help, it's because you don't understand what the compiler says, so your version of it does not help us ;)
"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 »

Ok my dear friends, let me be frank enough to tell you... am working in such a software company where there is only single machine which got Internet access.. And it cannot be shared, all USB ports are disabled, cannot be remotely logged in.. One CD rom was der, its not functioning.. And more over der is no intranet service..

So I am left out with only one option.. If number of errors are 1 to 5, den i can write down on a paper and come here on this machine and do the google search... I dont know how long i need to suffer.. Anyways, am sorry if i have violated any rule..

Anyways, first of all, I tried with the solution given by yakumoklesk.. After using this technique, i got rid of the error message "Too many include files".. But wxGetApp() is not working yet..
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 »

Actually the scenario is like this... I m using wxGLCanvas to display graphics.. I have derived a class BasicGLPane from wxGLCanvas.. And I have declared object of this class in my Frame Class.. I have set Statusbar in the frame.

What i actually want is, i want to display the pixel information on the statusbar. For this i have written a code for the MouseMove Event in BasicGLPane class. Now i dont have any means to go back to frame and set its statusbar's text with the pixel data.. Only way is to use

wxGetApp()->m_esplfrae->m_statusbar->SetStatusText();

But when i use this i get the reply back as,
wxGetApp: Undefined Identifier.
m_esplframe: needs struct/union or class to left of ->
same message for m_statusbar and SetStatusText() also..

Now how do i overcome this problem..?? As I told, i have Declared my APP also in ESPL.h as

DECLARE_APP(ESPL)

and

IMPLEMENT_APP(ESPL)

in ESPL.cpp

Now i have also followed Use only once headers technique (#ifndef, #define, #endif)

Waiting eagerly for solution.

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

Post by stevelam »

I think you need to use

wxGetApp().m_esplfrae->m_statusbar->SetStatusText();

Note the . rather than the -> after wxGetApp()
Ridmix
Knows some wx things
Knows some wx things
Posts: 40
Joined: Sat Dec 01, 2007 9:27 am

Post by Ridmix »

app.h

Code: Select all

#ifndef __APP_H__
#define __APP_H__

#include <wx/app.h>

class App : public wxApp
{
public:
    bool OnInit();
    wxString GetName() const {wxT("App");}
};

DECLARE_APP(App);

#endif // __APP_H__
app.cpp

Code: Select all

#include "app.h"

IMPLEMENT_APP(App);

bool App::OnInit()
{
   // create frame etc.
    return true;
}
mainframe.cpp

Code: Select all

#include "app.h"
// ctor & dtor
void MainFrame::Test() 
{
    wxGetApp().GetName();
}
It must work!
rakeshthp wrote: wxGetApp()->m_esplfrae->m_statusbar->SetStatusText();
wxGetApp() return reference! not a pointer!!
http://cplus.about.com/od/learning1/ss/references.htm
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.. Initially, i had used the same..

wxGetApp().m_esplframe.. That's also not working..is there anything about wxTheApp.?? will that be of any use for me..???
Ridmix
Knows some wx things
Knows some wx things
Posts: 40
Joined: Sat Dec 01, 2007 9:27 am

Post by Ridmix »

Me works

Show source code! eh
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 »

Infact, i think, i have got some hint.. Is there any restriction to include MainApp.h (ESPL.h in my example)..?? Coz, i observed one thing just now..

There are four classes..
ESPL
FrameEX
BasicGLPane
ETreeWindow

ESPL is the main program which implements app.
FrameEX is derived from wxFrame.
BasicGLPane is derived from wxGLCanvas.
And, ETreeWindow is derived from wxTreeCtrl.

Now, I have declared an object of FrameEX in ESPL. So I got to include FrameEX in ESPL. And am including BasicGLPane in FrameEX, as i want GLCanvas to be displayed in the frame. Another am using the object of ETreeWindow in FrameEX.

Now the funniest part is I included ESPL.h in both, BasciGLPane and ETreeWindow, and it is working fine with ETreeWindow, but giving error with BasicGLPane.

Now i used
wxGetApp().m_esplframe->m_statusbar->tStatusText();

and the error what am getting is in FrameEX file. And cursor is pointing to the line where i had declared these two objects

BasicGLPane *m_graphics;
ETreeWindow *m_tree;

And the Error message is

error C2143: syntax error : missing ';' before '*'

Whereas i check whole code whether ';' is missing any where.. :) but no use..

Any comments on this..?

Thanks and Regards
Rakesh Patil
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 »

One more thing i forgot..

If i dont include in BasicGLPane and include in ETreeWindow, the it runs without any error or warnings...
mentat
Knows some wx things
Knows some wx things
Posts: 30
Joined: Thu Mar 20, 2008 4:03 pm

Post by mentat »

Sory to interrupt, I might be missing sth but, doesn't ::wxLogStatus is what you need?
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 »

Hey thanks der...

But it solves only one prob of displaying pixel information... There are somemore functions also that need to be executed.. ther wxLogstatus wont be useful i guess...

What say??
Ridmix
Knows some wx things
Knows some wx things
Posts: 40
Joined: Sat Dec 01, 2007 9:27 am

Post by Ridmix »

rakeshthp wrote:Infact, i think, i have got some hint.. Is there any restriction to include MainApp.h (ESPL.h in my example)..?? Coz, i observed one thing just now..

There are four classes..
ESPL
FrameEX
BasicGLPane
ETreeWindow

ESPL is the main program which implements app.
FrameEX is derived from wxFrame.
BasicGLPane is derived from wxGLCanvas.
And, ETreeWindow is derived from wxTreeCtrl.

Now, I have declared an object of FrameEX in ESPL. So I got to include FrameEX in ESPL. And am including BasicGLPane in FrameEX, as i want GLCanvas to be displayed in the frame. Another am using the object of ETreeWindow in FrameEX.

Now the funniest part is I included ESPL.h in both, BasciGLPane and ETreeWindow, and it is working fine with ETreeWindow, but giving error with BasicGLPane.

Now i used
wxGetApp().m_esplframe->m_statusbar->tStatusText();

and the error what am getting is in FrameEX file. And cursor is pointing to the line where i had declared these two objects

BasicGLPane *m_graphics;
ETreeWindow *m_tree;

And the Error message is

error C2143: syntax error : missing ';' before '*'

Whereas i check whole code whether ';' is missing any where.. :) but no use..

Any comments on this..?

Thanks and Regards
Rakesh Patil
Apparently the problem is in your code, not in wxWidgets.
Learn the basics C++
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 »

If your indication is towards forward declaration then i have done that also.. but result is same
mentat
Knows some wx things
Knows some wx things
Posts: 30
Joined: Thu Mar 20, 2008 4:03 pm

Post by mentat »

rakeshthp wrote:Hey thanks der...

But it solves only one prob of displaying pixel information... There are somemore functions also that need to be executed.. ther wxLogstatus wont be useful i guess...

What say??
what do you mean? You want to display info in statusbar. And I told you how to do it? Can you please state your above sentences in clear English?
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 »

I mean to say that there are few functions in FrameEX which I want to access in the BasicGLPane class. So in order to do so, is there any method other than using wxGetApp()..??
Post Reply