Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Getting a pointer to CAknViewAppUi or CAknView

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Tested with
Devices(s): Nokia N95
Keywords: CAknView, CAknViewAppUi
Created: tepaa (07 Mar 2008)
Last edited: hamishwillee (17 Jul 2012)


These examples help you get a reference to the CAknViewAppUi and CAknView classes in the S60 Avkon view-switching architecture.

Source file

If your application has one application UI class that is derived from CAknViewAppUi, you can get a pointer to your view from that class as follows:

// Get a pointer to CAknView from CAknViewAppUi
// ESomeViewId is the view enumeration id value in your application .hrh file.
CSomeView* view = (CSomeView*)View(TUid::Uid(ESomeViewId));

If you have at least one view class that is derived from CAknView, you can get a pointer to the application UI class from that class as follows:

// Get a pointer to CAknViewAppUi from CAknView
CYourAppUi* appUi = (CYourAppUi*)AppUi();

You can get a pointer to a view from another view as follows:

// Get a pointer to CAknView from CAknView
CSomeView* view = (CSomeView*)AppUi()->View(TUid::Uid(ESomeViewId));

CAknViewAppUi lives as long as your application is running, so it is a good place to store the engine class (in its class member). You can get a pointer to your engine as follows:

// Get a pointer to your engine class from CAknView
CYourApplicationAppUi* appui = (CYourApplicationAppUi*)AppUi();
CYourAppEngine* engine = appui->Engine();

Note: You must implement the CYourApplicationAppUi::Engine() method in order to use the code above.

Getting pointers by iEikonEnv in CCoeControl class:

// Get the application UI from CEikonEnv
CYourApplicationAppUi* appui = (static_cast<CYourApplicationAppUi*>(iEikonEnv->AppUi()));
// Get the view you want
CSomeView* view = (CSomeView*)appui->View(TUid::Uid(ESomeViewId));

See also

This page was last modified on 17 July 2012, at 04:16.
65 page views in the last 30 days.