是否有对应于 HWND 的 class 菜单的 window 样式?

Is there a window style that corresponds to a HWND's class menu?

Windows 有多个 window 样式对应于 window 和 SetWindowLongPtr 的属性,与参数 GWL_EXSTYLEGWL_STYLE,可用于切换这些属性 ON/OFF。例如,WS_CAPTION 可用于切换 window 的标题栏 ON/OFF。我想知道是否有一种 window 样式对应于切换 HWND ON/OFF 的 class menu

注意:我知道 class 菜单可以通过 SetMenu API 切换,但我很好奇是否也有相应的 window 样式。

谢谢。

没有与 window 的菜单相对应的样式。通过将 WNDCLASSEX 结构的 lpszMenuName 字段设置为有效的菜单资源名称或 NULL(如果没有 class 菜单),可以打开和关闭 class 菜单被要求。

请注意 window class 是创建 window 的模板。创建 window.

时,您可以在对 CreateWindowEx 的调用中覆盖菜单条目

没有window样式,但是有class值。

当 window class 通过 RegisterClass()/RegisterClassEx(), the WNDCLASS/WNDCLASSEX 结构注册时有一个 lpszMenuName 成员:

lpszMenuName
Type: LPCTSTR

The resource name of the class menu, as the name appears in the resource file. If you use an integer to identify the menu, use the MAKEINTRESOURCE macro. If this member is NULL, windows belonging to this class have no default menu.

您可以使用 SetClassLong()/SetClassLongPtr() 并将其 nIndex 参数设置为 GCLP_MENUNAME 来更改给定 [= 使用的 class 的 lpszMenuName 值36=].