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 over the next few weeks. Thanks for all your past and future contributions.

Identifying the menubar associated with an application using FEP

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): All (S60)
Platform(s): S60 3rd Edition FP1
S60 3rd Edition FP2
S60 5th Edition
S60 5th Edition
S60 3rd Edition FP2
S60 3rd Edition FP1
Keywords: IsDisplayingMenuOrDialog, CAknViewAppUi
Created: User:Kbwiki (11 Dec 2009)
Last edited: hamishwillee (01 Aug 2012)



This article gives an overview of identifying the type of menu bar associated with an application.


The menu bar of an S60 application can be view-based, dialog-based, or the one from the standard Eikon environment. Knowledge of the type of a menu bar associated with a foreground application can be sometimes required in the implementation of a 3rd party Front End Processor (FEP).

A FEP acts as an interface between the user and an application. It intercepts the events, processes them according to its own logic, and then sends one or more events to the focused application. Whenever a menu bar is activated, its type can be identified using the code provided in this article.


The following sample code can be used for resolving the menu bar associated with an application.


 #include <aknappui.h>
#include <eikmenub.h>

DialogMenuBar() implementation

 CEikMenuBar* DialogMenuBar( CAknAppUi* aAppUi )
CEikMenuBar* menuBar = NULL;
// Check for an active dialog and fetch its menu bar
if ( aAppUi->IsDisplayingMenuOrDialog() )
CCoeControl* ctrl = aAppUi->TopFocusedControl();
if ( ctrl )
CEikDialog* dialog = ctrl->MopGetObjectNoChaining( dialog );
if ( dialog )
dialog->MopGetObject( menuBar );
return menuBar;

ViewMenuBar() implementation

 CEikMenuBar* ViewMenuBar( CAknAppUi* aAppUi )
CEikMenuBar* menuBar = NULL;
// Check for an active view
TVwsViewId uid;
if ( aAppUi->GetActiveViewId( uid ) == KErrNone )
if ( uid.iAppUid != uid.iViewUid )
CAknView* view = static_cast<CAknViewAppUi*>( aAppUi )->View( uid.iViewUid );
if ( view )
menuBar = view->MenuBar();
return menuBar;

Using the above functions, the type of the menu bar can be resolved as follows:

 // Try fetching a menu bar from currently displayed dialog
CEikMenuBar* menuBar = DialogMenuBar( iAvkonAppUi );
if ( !menuBar ) // Menu bar was not dialog based
// Try fetching a menu bar from an active view
menuBar = ViewMenuBar( iAvkonAppUi );
if ( !menuBar ) // Menu bar was not view based
// Finally, try fetching a menu bar from AppUi
menuBar = CEikonEnv::Static()->AppUiFactory()->MenuBar();

After this, new menu items can be added dynamically with the DynInitMenuPaneL() function.

See also

Archived:Adding menu items dynamically using Symbian C++

This page was last modified on 1 August 2012, at 04:40.
45 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.