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.
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: LPCTSTRThe 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.