Archived:Getting a pointer to CAknViewAppUi or CAknView
The article is believed to be still valid for the original topic scope.
Article Metadata
Tested with
Compatibility
Article
Overview
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));


(no comments yet)