wxGetApp, etc.

78 views
Skip to first unread message

Tim Burgess

unread,
May 2, 2012, 8:47:47 AM5/2/12
to wx-u...@googlegroups.com

Hi,

 

I need to use wxGetApp() from within some modules aside from the .cpp that implements my actual application class.  I understand that I need to create a forward definition using   DECLARE_APP(MyApp), but I’m confused as to where I should place the declaration – should it be within the private: section of my application class definition?  If so, I assume that I then need to include my application’s header file in any sub-module that needs to use wxGetApp()?

 

Best wishes.

 

Tim Burgess

Raised Bar Ltd

Phone:  +44 (0)1827 719822

 

Don't forget to vote for improved access to music and music technology at

 

http://www.raisedbar.net/petition.htm

 

 

Vadim Zeitlin

unread,
May 2, 2012, 8:59:19 AM5/2/12
to wx-u...@googlegroups.com
On Wed, 2 May 2012 13:47:47 +0100 Tim Burgess wrote:

TB> I need to use wxGetApp() from within some modules aside from the .cpp that
TB> implements my actual application class. I understand that I need to create
TB> a forward definition using DECLARE_APP(MyApp), but I'm confused as to
TB> where I should place the declaration - should it be within the private:
TB> section of my application class definition? If so, I assume that I then
TB> need to include my application's header file in any sub-module that needs to
TB> use wxGetApp()?

wxDECLARE_APP() (the version without "wx" prefix still exists but we
recommend using wx-prefixed macros) is just a declaration of wxGetApp()
function so you should use it at top level. And you do need to include the
header containing it to be able to use it, this is the whole point of
declaring this function there.

E.g.

// MyApp.h
class MyApp : public wxApp { ... };

wxDECLARE_APP(MyApp);

// SomeOtherFile.cpp
#include "MyApp.h"

... use wxGetApp().AnyMyAppMethod() ...

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Tim Burgess

unread,
May 2, 2012, 10:41:42 AM5/2/12
to wx-u...@googlegroups.com
Got it and problem solved - many thanks.

Best wishes.

Tim Burgess
Raised Bar Ltd
Phone: +44 (0)1827 719822

Don't forget to vote for improved access to music and music technology at

http://www.raisedbar.net/petition.htm



-----Original Message-----
From: wx-u...@googlegroups.com [mailto:wx-u...@googlegroups.com] On Behalf
Of Vadim Zeitlin
Sent: 02 May 2012 13:59
To: wx-u...@googlegroups.com
Subject: Re: wxGetApp, etc.

On Wed, 2 May 2012 13:47:47 +0100 Tim Burgess wrote:

TB> I need to use wxGetApp() from within some modules aside from the
TB> .cpp that implements my actual application class. I understand that I
need to create
TB> a forward definition using DECLARE_APP(MyApp), but I'm confused as to
TB> where I should place the declaration - should it be within the private:
TB> section of my application class definition? If so, I assume that I
TB> then need to include my application's header file in any sub-module
TB> that needs to use wxGetApp()?
Reply all
Reply to author
Forward
0 new messages