Symbian
Symbian OS Library

FAQ-0802 How do I add a menu item dynamically?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: EIKON
Created: 06/14/2002 Modified: 06/28/2002
Number: FAQ-0802
Platform: Symbian OS v6.0, Symbian OS v6.1

Question:
I know you can change a menu dynamically, but how do you do it if the resources are not predefined in the resource file but defined at run time?


Answer:
You can create a new menu item in the DynInitMenuPaneL(...) method of your CEikAppUi with something like the following code (which puts a "No tasks" item onto the task list menu pane on a 9200 series Communicator):

CEikMenuPaneItem::SData data;
HBufC* text=iEikEnv.AllocReadResourceLC(R_CKN_TASK_LIST_NO_TASKS);
data.iText=*text;
CleanupStack::PopAndDestroy(text);
const TInt cmdId=ECknTasksAutoMenuStart;
data.iCommandId=cmdId;
data.iCascadeId=0;
data.iFlags=0;
data.iExtraText=KNullDesC;
aMenuPane.AddMenuItemL(data);