Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 16:02, 31 May 2008.

CS000848 - Getting a pointer to CAknViewAppUi or CAknView

From Forum Nokia Wiki


ID CS000848 Creation date March 7, 2008
Platform S60 3rd Edition Tested on devices Nokia N95
Category Symbian C++ Subcategory UI
APIs None Classes CAknView
CAknViewAppUi
Methods None    


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));

See also

Related Discussions
Thread Thread Starter Forum Replies Last Post
Compile error, dll has initialized data JohnsonZ General Symbian C++ 3 2008-01-18 01:38
how to capture pointer event? h_01cs25 General Discussion 0 2006-03-30 15:04
Pointer event- Tab control Alicia_S60 Mobile Java General 0 2004-12-14 10:12
Please help!!! emergency zhang_guoqing General Symbian C++ 1 2003-04-15 07:50
Closing a CAknViewAppUi dialog danirridescent Symbian User Interface 5 2007-09-25 14:49
 
Powered by MediaWiki