0

Windows has a number of window styles that corresponds to attributes of a window, and SetWindowLongPtr, used with parameters GWL_EXSTYLE or GWL_STYLE, can be used to toggle these attributes ON/OFF. For example, WS_CAPTION can be used to toggle a window's title bar ON/OFF. I was wondering if there's a window style that corresponds to toggling the class menu of a HWND ON/OFF as well.

Note: I understand that the class menu can be toggled via the SetMenu APIs, but was just curious if there's a corresponding window style as well.

Thanks.

IInspectable
  • 46,945
  • 8
  • 85
  • 181
lancery
  • 658
  • 1
  • 6
  • 18

2 Answers2

2

There is no window style, but there is a class value instead.

When a window class is registered via RegisterClass()/RegisterClassEx(), the WNDCLASS/WNDCLASSEX structure has an lpszMenuName member:

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.

You can use SetClassLong()/SetClassLongPtr() with its nIndex parameter set to GCLP_MENUNAME to change the lpszMenuName value for the class used by a given window.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • *You can use SetClassLong()/SetClassLongPtr() with its nIndex parameter set to GCLP_MENUNAME to change the lpszMenuName value for the class used by a given window.* - You can, but it won't have any effect on any given window. The class menu is only evaluated when creating a window. – IInspectable Oct 13 '16 at 10:47
1

There is no style that corresponds to a window's menu. The class menu is toggled on and off by setting the lpszMenuName field of the WNDCLASSEX structure to a valid menu resource name or NULL, if no class menu is requested.

Note that a window class is a template to create a window. You can override the menu entry in your call to CreateWindowEx when creating a window.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
IInspectable
  • 46,945
  • 8
  • 85
  • 181