dynamically adding menu items

Login to reply to this topic.
Wed, 2004-12-29 08:50
Joined: 2004-09-06
Forum posts: 349
I have the resources

Code:
RESOURCE DIALOG r_dlg {
 flags = ...
 buttons = r_btns;
 form = r_form;
}

RESOURCE CBA r_btns {
 buttons = {
   CBA_BUTTON {
     id = EAknSoftkeyOptions;
     txt = "Alternativ";
   },
   CBA_BUTTON {
     id = EAknSoftkeyExit;
     txt = "Avsluta";
   }
 };
}

RESOURCE FORM r_form {
 flags = ...
 items = {
   DLG_LINE {
     type = EEikCtEdwin;
     prompt = "Förnamn";
     id = ESomeId;
     control = EDWIN {
       ...
     };
   }, ...
 }
}

Now, I want to add menu items to the Options menu with Edit as a menu choice (which automatically comes from EAknSoftkeyOptions). I then try to do this dynamically in the DynInitMenuPaneL function, like this:

Code:
void CMyForm::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
 CAknForm::DynInitMenuPaneL(aResourceId, aMenuPane);

 if (aResourceId == 147587078)  //I have no idea where this number is defined. Anyone....??
   CEikMenuPaneItem::SData mpi;
   mpi.iCommandId = E1;
   mpi.iText.Copy(_L("Hej"));
   aMenuPane->AddMenuItemL(mpi);
 }
}

I thought that this code would only enter the if statement once (which it also does) but instead of getting one more menu choice "Hej", I get a menu choice "Hej" with a submenu arrow to a submenu that does not exist! There is a panic (CONE 14 - resource not found) when I try to go to the submenu. What has happened here?Huh??

Wed, 2004-12-29 14:23
Joined: 2004-01-06
Forum posts: 18
dynamically adding menu items
How about if you but those items in resource and dim those items which you don't need in DynInitMenuPaneL(...)
  • Login to reply to this topic.