我想知道是否可以获取信息,Windows窗口中是否有菜单。
此信息将用作 AdjustWindowRect
的第三个参数。如果可能,我不想自己保存这些信息。
最佳答案
如果窗口已经创建,您可以调用 GetMenu ,传递窗口句柄。如文档中所述:
If the specified window has no menu, the return value is NULL.
另一方面,如果你需要知道一个尚未创建的窗口是否默认有一个菜单1),你可以通过调用GetClassInfo查询类信息, 并比较返回的 WNDCLASS ' lpszMenuName 成员。同样,正如文档所解释的那样:
If this member is NULL, windows belonging to this class have no default menu.
1) 请注意,窗口仍然可以通过调用 SetMenu 在运行时添加或删除菜单。
关于c++ - 查看窗口是否有菜单栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37729096/