C++ Windows API : disabled menu grayed?

标签 c++ windows winapi

<分区>

我正在测试 Windows API 的菜单状态(禁用、变灰、选中...),但有些东西我不明白。 documentation指出 MF_DISABLED 不会使项目变灰,但这是我得到的:

enter image description here

使用此代码:

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);

我怎样才能让一个禁用的菜单项不变灰呢?

最佳答案

这两个现在是一样的。参见 tagMENUITEMINFOA获取更多信息。

MFS_DISABLEDMFS_GRAYED 现在都是灰色的,因为它们代表相同的值 0x00000003L

关于C++ Windows API : disabled menu grayed?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53670826/

相关文章:

c++ - 在 iOS : "Undefined symbols" and "ld: warning: ignoring file" 中为 C++ 编译 Protobuf 时出错

服务器和客户端是否可以在同一个端口上发起通信并发送命令?

c++ - 将 Windows 视觉主题与 Code::Blocks 一起使用?

windows - 需要在 github 操作工作流程中将反斜杠转换为正斜杠

c# - 如何从 Windows 7 上的 C# 程序读取 Android 手机上的文件?

opengl - SetPixelFormat() 中的 PIXELFORMATDESCRIPTOR 参数是做什么用的?

c++ - 我可以从对话框的 DoModal 函数返回自定义值吗?

c++ - 位操作 - 对于负数

c++ - 如何在类中声明一个 const size_t?

c++ - static const的C++容器初始化列表导致栈溢出