Adding icons to a pulldown menu

Hi folks,

I only recently realised this was possible when I stumbled upon DItem_PulldownIconMenuRsc. I couldn't find any example code, but I did some testing and managed to get it to work using a definition like this:

DItem_PulldownIconMenuRsc PDMENUID_FILE_Export   =
{   
NOHELP, OHELPTASKIDCMD, NOHOOK, ON | ALIGN_LEFT, "",   
{   
{DLGTXT_Export,   NOACCEL, ON,  NOMARK, 0, NOSUBMENU, NOHELP, OHELPTASKIDCMD, NOHOOK, 0, NOCMD,OTASKID, "", ICONID_SaveTool, Icon, OTASKID
}
};

This works fine unless I want to use my own icon instead of the builtin icon "ICONID_SaveTool". With my own icons I can't get this to work - I just get a blank icon. I have tried defining icons with 16x16x256 colours, as well as the small and large icon resources and even 32-bit colour icons, but nothing seems to work. I've also tried defining "IconTiny" instead of "Icon", IconCmdX, etc. I can't see what is magically different between my own icons and the built-in icons that stops mine from working in menus.

Has anyone got a custom defined icon to display in a pulldown menu, and if so what is the magic step? I know my icons are defined correctly because on the same dialog I can display an IconCmdX with no problems. So it seems there is some property or setting or maybe icon format that I am missing that stops my icons from working.

Any advice appreciated!

 

Parents
  • Okay I figured it out. It looks like menu icons differ from dialog icons in a couple of key ways:

    1) For some reason the owner task ID must be set to the application. OTASKID is not sufficient for menu icons, even though it works for an IconCmdX. Oddly, OTASKID does work for MicroStation icons, even though you are supposed to specify MTASKID (in theory).

    2) The icon type must match a defined type. If I define only an IconRsc, then an IconCmdX will automatically find the tiny, small and large resources automatically if they exist in the icon definition. However for a menu icon, this will not happen and the icon will be blank if you ask for a size that isn't defined. So you can specify IconSmall, IconTiny and Icon for the icon type (probably IconLarge too but I didn't try), but that corresponding type must be defined. I think this means MicroStation won't automatically pick up the best size to fit the menu text height.

    Hope this helps someone else.

    --
    Piers Porter
    Altiva Software

  • Piers are you doing this for the main menu bar? Can you post a jpg of your pull down?

    Kirk

    I Wish Cadland was Reality

  • Unknown said:

    Piers are you doing this for the main menu bar? Can you post a jpg of your pull down?

    Sure, see below. This is on my own dialog, not the Main Menu, though I am sure the same principles apply. I used the IconTiny size, not sure if that is the same as the Bentley main menu, but we're flying blind here.

     

    --
    Piers Porter
    Altiva Software

  • Hi Piers,

    I am asked this similiar question recently by a Chinese developer. And I found using IconRsc can also work.

    My tested MicroStation version is V8iSS3Update2.

    Regards, YongAn



Reply Children
No Data