Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ windows api: disabled menu grayed? [duplicate]

I'm testing the windows API's menu states (disabled, grayed, checked...) but there's something I don't understand. The documentation states that MF_DISABLED does not gray an item but here's what I get:

enter image description here

with this code:

HMENU menuBar = CreateMenu();
HMENU hopMenu = CreateMenu();

AppendMenuW(menuBar, MF_POPUP, (UINT_PTR)hopMenu, L"hop");
AppendMenuW(hopMenu, MF_STRING, 0, L"Enabled");

AppendMenuW(hopMenu, MF_STRING | MF_DISABLED, 1, L"Disabled");
AppendMenuW(hopMenu, MF_STRING | MF_GRAYED, 2, L"Grayed");
AppendMenuW(hopMenu, MF_STRING | MF_CHECKED, 3, L"Checked");

AppendMenuW(hopMenu, MF_STRING | MF_DISABLED | MF_CHECKED, 4, L"Disabled && Checked");
AppendMenuW(hopMenu, MF_STRING | MF_DISABLED | MF_GRAYED, 5, L"Disabled && Grayed");

AppendMenuW(hopMenu, MF_STRING | MF_CHECKED | MF_GRAYED, 6, L"Checked && Grayed");

SetMenu(hwnd, menuBar);

How can I have a disabled menu item not grayed, then?

like image 772
Charles S. Avatar asked Dec 07 '18 13:12

Charles S.


1 Answers

These two are now the same. See tagMENUITEMINFOA for more info.

Both MFS_DISABLED and MFS_GRAYED are grayed now as they represent the same value of 0x00000003L

like image 98
Ron Avatar answered Oct 11 '22 15:10

Ron