get access to AppUI members

Login to reply to this topic.
Sat, 2006-02-25 13:44
Joined: 2006-02-24
Forum posts: 13
Hi! How can I get access to AppUi member functions and variables from things like containers which are contained within views which are in turn contained in the AppUi? Do I need to pass a reference to the AppUi to the container or is there a better way? I have seen iEikonEnv being used as follows:

Code:
STATIC_CAST(CdiscoveryAppUi*, iEikonEnv->EikAppUi())->iBTManager->StartDeviceInquiryL( iDevices, this );

where CdiscoveryAppUi is my AppUi class.

But the above code gives me an error : 'static_cast' : cannot convert from 'CEikAppUi *' to 'CdiscoveryAppUi *'

Mon, 2006-02-27 03:29
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: get access to AppUI members
Quote from: fahadkhowaja
where CdiscoveryAppUi is my AppUi class.

But the above code gives me an error : 'static_cast' : cannot convert from 'CEikAppUi *' to 'CdiscoveryAppUi *'

From which class did you derive the class CdiscoveryAppUi?

Quote
static_cast can perform conversions between pointers to related classes, not only from the derived class to its base, but also from a base class to its derived. Such conversions rely on static (compile-time) type information.

Please make sure that you have derived CdiscoveryAppUi from correct base class. From your post it's clear that you are using views and containers. So your CdiscoveryAppUi class might be derived from CAknViewAppUi.

Mon, 2006-02-27 19:53
Joined: 2006-02-24
Forum posts: 13
Re: get access to AppUI members
Yes you are right, my AppUi is derived from CAknViewAppUi. So then is this the only way (bar passing in a reference to the AppUi to the function) of accessing AppUi members from outside it?

Which is a better approach, static casting or passing in a reference, or does it make any difference at all?
Tue, 2006-02-28 11:29
Joined: 2004-12-23
Forum posts: 239
Re: get access to AppUI members
Hi fahadkhowaja,

You can try like this

CMyAppUi* myAppUi= (CMyAppUi *)iCoeEnv->AppUi();

BR

---------------
Bhatt Kavita

Wed, 2006-03-01 02:59
Joined: 2004-05-20
Forum posts: 8
Re: get access to AppUI members
maybe?

CMyAppUi* myAppUi= dynamic_cast<CMyAppUi *>(iCoeEnv->AppUi());

if(myAppUi == NULL)
    ;// i missed my-App UI
else
    ;// I got my-App UI

Experience is a good teacher..
Are you a good student ?

Wed, 2006-03-01 10:51
Joined: 2004-12-23
Forum posts: 239
Re: get access to AppUI members
oh sorry I forgot to put this line
//
CMyAppUi* myAppUi= dynamic_cast<CMyAppUi *>(iCoeEnv->AppUi());
//

---------------
Bhatt Kavita

Thu, 2006-03-02 08:25
Joined: 2004-05-20
Forum posts: 8
Re: get access to AppUI members
Opps!! from docks it seems like dynamic_cast is not supported by Symbian OS Sad

reinterpret_cast should be fine..

Experience is a good teacher..
Are you a good student ?

Sat, 2006-03-04 07:11
Joined: 2004-12-23
Forum posts: 239
Re: get access to AppUI members
Ya hack_tick
you r right..
It may be used like this

#define  APPUI STATIC_CAST(CMyAppUi*, iCoeEnv->AppUi())

Thanks for correcting me

---------------
Bhatt Kavita

Sun, 2006-03-05 06:41
Joined: 2004-12-23
Forum posts: 239
Re: get access to AppUI members
Hi hack_tick

I also gone through docs...but why symbian doesn't support dynamic_cast.

BR

---------------
Bhatt Kavita

  • Login to reply to this topic.