×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Hyderabad, India
    Posts
    90

    How to place icon on the menu?

    Hi,

    I wanna put icons in my menu. I am try the following code but I am getting a system error.

    void CGameAppUi::DynInitMenuPaneL(
    TInt aResourceId,CEikMenuPane* aMenuPane)
    {
    if (R_GAME_MAIN_MENU == aResourceId)
    {

    // Trying to put icon in the menu item
    CEikMenuPaneItem* menuItem;
    TInt position;
    CFbsBitmap* bitmap;
    CFbsBitmap* bitmapMask;

    bitmap = NBitmapMethods::CreateBitmapL(KMultiBitmapFilename,EMbmGameimagesHero);
    bitmapMask = NBitmapMethods::CreateBitmapL(KMultiBitmapFilename,EMbmGameimagesHero_mask);


    menuItem = aMenuPane->ItemAndPos(ETouchTimeNewGame, position);
    menuItem->SetIconBitmapL(bitmap);
    menuItem->SetIconMaskL(bitmapMask);
    menuItem->SetBitmapsOwnedExternally(ETrue);

    delete menuItem;
    menuItem = NULL;
    delete bitmap;
    bitmap = NULL;
    delete bitmapMask;
    bitmapMask = NULL;

    }

    }

    Can some please point out there the error is ?

    Thanks

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165
    Hi

    There seems to be multiple problems in your code. Basically you need to clarify the object ownership issue to your self to get it work.

    Firstly you are taking a pointer to a menuItem, which mean that you are getting a pointer to a onbject, which you dont own, it's still owned by your menupane, so wwhen you delete it later you are deleting something you dont own and causing a your system to crash.

    secondly you are setting a bitmap and a mask for it, by first constructing two bitmap objects. So when you construct them you own them, then when you set the to be used by the menupane, the ownership is moved to the menupane. But then you say SetBitmapsOwnedExternally(), so then you keep owning the bitmaps and the menupane is merely using the pointers.

    But then you go and delete the bitmaps, so if the menupane would try using the pointers they wouldn't be valid any more and your application would crash. This propably wont happen since it already crashed because of the first problem.

    So the solution is easy dont delete the menuitem, dont set bitmap ownership to your self, let the menupane own it's icons and then do not delete the bitmaps, since you dont own them after you have set them to the menupane.


    Easiest way to do it all would be propably to use SetIcon()-function, and you could make the icon by using CEikonEnv's CreateIconL()-function.

    yucca

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Hyderabad, India
    Posts
    90
    Thanks a lot Yucca

    I figured figured out the problem.

    :)

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    93

    Can I place an icon by using the RSS file?

    Hi Yucca,

    Can I place an icon on the menu and cascaded menu? Can I added the mbm file name, the bmpid, bmpmaskid to RSS? I'm using Series 60 v2.1 and v2.2. Here is one of my sample code in RSS file:

    MENU_ITEM {
    command = EMyappCmdHelp;
    txt = HELP_TITLE_TEXT ;
    bmpfile = "\\System\\Apps\\MyApp\\MyApp.mbm";
    bmpid = EMbmMyappHelp;
    bmpmask = EMbmMyappHelp_mask;
    },

    It seems nothing show on the emulator. Please help me.
    Also, when I read the SDK for MENU_ITEM, it said it was "Withdrawn in 7.0s". Why? Is it no longer support? And how should we construct the menu?
    Thanks.

    luke

  5. #5
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Bangalore,India
    Posts
    306
    I am also not able to place icon to menu using Resource File
    I am not able to place icon on CBA too though Series60 provides special resource to do it.
    Can anyone help?

  6. #6
    Registered User
    Join Date
    Feb 2004
    Posts
    124
    Just because there is a call for doing so does not mean that you can do it.

    Many things are defined by the superclass, but they are actually not implemented by the subclass. That is life.

    You can but filter for just showing wap accesspoints, but inet only and mms are shown too.

    You can change colors or avcon dialogs, but they do not change.

    I cannot say what you talk cannot be done using standard dialogs, but I have seen not seen any application doing so.

  7. #7
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Bangalore,India
    Posts
    306
    i use following code but i am still not able to display icon in menu. Can anyone help me?

    TInt position;
    CEikMenuPaneItem* menuItem = aMenuPane->ItemAndPos(EClientPocketCmdOpen, position);
    menuItem->SetIcon( CEikonEnv::Static()->CreateIconL( KIconFile, EMbmClientpocketimageListboximage, EMbmClientpocketimageListboximagem) );

  8. #8
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Bangalore,India
    Posts
    306
    Luckily today i checked my code on N3650 and guess what?
    Icon are displayed in Menu.

    But............ When i installed it on N6600, icons disappear.

    So just be aware :p

  9. #9
    Registered User
    Join Date
    Jul 2004
    Posts
    93

    No more icon on menu?

    Hi SymbianSandy,

    Many reports said that Series 60 v 2.0 and so on no longer support icon on menu. Many people tried both RSS (static) and cpp (dynamic) ways and still icon didn't show up.

    I am very wonder if MENU_ITEM will be replace soon because when I look up MENU_ITEM in SDK API help, it said it's withdraw in 7.0s.

    luke

  10. #10
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Bangalore,India
    Posts
    306
    u r right. MENU_ITEM is removed from SDK. But there must be some other way supported by SDK to create Menu. Do you know it?

    One more issue... SDK provides resource for CBA..special resource of AKN where i can get parameters to add images/icons to CBAs but in reality, it is not seen.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×