Author Topic: Context menu icons  (Read 3073 times)

0 Members and 1 Guest are viewing this topic.

Offline DeathSlayer

  • Newbie
  • *
  • Posts: 2
Context menu icons
« on: 08 11 2014, 13:24:19 »
Hello,
I noticed that "Status" context menu (with Online, Offline, AFK, ... items) contains items with icon on checkbox (for example: currently selected status), and I want to make the same in my application, but I don't know how it is implemented.
I searched it in source code and I didn't find anything. I tried to set fState = MFS_CHECKED and fMask = MIIM_BITMAP, but icon disappeared.
Could someone tell me how it is done, or in which file I can find it, please?
Thank you for your answer.
 

Offline Wishmaster

Re: Context menu icons
« Reply #1 on: 08 11 2014, 13:45:37 »
Are you sure you properly initialized the hbmpItem member of your MENUITEMINFO structure (see here)?
 

Offline DeathSlayer

  • Newbie
  • *
  • Posts: 2
Re: Context menu icons
« Reply #2 on: 08 11 2014, 14:25:11 »
I think so. I see only checkbox with tickmark and if I remove "mii.fState |= MFS_CHECKED;", then icon is there, but checkbox isn't.
Here is my (simplified) code:
Code: [Select]
hMenu = CreatePopupMenu();

MENUITEMINFO mii = { sizeof(mii) };
mii.fMask = MIIM_DATA | MIIM_ID | MIIM_STRING;
if (hIconItem)
{
    mii.fMask |= MIIM_BITMAP;
    mii.hbmpItem = hIconItem;
}

mii.fMask |= MIIM_STATE;
mii.fState = MFS_ENABLED;
mii.fState |= MFS_CHECKED;

mii.dwTypeData = L"Some text";

InsertMenuItem(hMenu, 0, true, &mii);

Post Merge: 08 11 2014, 20:40:23
I solved my problem. I used this code and I realized it does something different than I want, so I removed it and it works now:
Code: [Select]
MENUINFO mi = { sizeof(mi) };
mi.fMask = MIM_STYLE;
mi.dwStyle = MNS_CHECKORBMP;
SetMenuInfo(hMenu, &mi);

Thanks anyway
« Last Edit: 08 11 2014, 20:40:23 by DeathSlayer »