- 第一种方法,用ModiftMenu()涵数来实现:
- CMenu* pMenu = this->GetSystemMenu(FALSE);
- pMenu->ModifyMenu(SC_CLOSE,MF_BYCOMMAND | MF_GRAYED );
- 第二种方法,用EnableMenuItem()涵数来实现:
- CMenu* pMenu = this->GetSystemMenu(FALSE);
- pMenu->EnableMenuItem( SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
The GetSystemMenu function allows the application to access the window menu (also known as the system menu or the control menu) for copying and modifying.
Syntax
HMENU GetSystemMenu(
HWND hWnd, BOOL bRevert );
Parameters
hWnd
- [in] Handle to the window that will own a copy of the window menu.
bRevert- [in] Specifies the action to be taken. If this parameter is FALSE, GetSystemMenu returns a handle to the copy of the window menu currently in use. The copy is initially identical to the window menu, but it can be modified. If this parameter is TRUE, GetSystemMenu resets the window menu back to the default state. The previous window menu, if any, is destroyed.
Return Value
If the bRevert parameter is FALSE, the return value is a handle to a copy of the window menu. If the bRevert parameter is TRUE, the return value is NULL.
禁用关闭菜单项
本文介绍了两种禁用窗口菜单中关闭选项的方法。一种是通过使用 ModifyMenu 函数,另一种则是利用 EnableMenuItem 函数。这两种方法都需要获取窗口菜单句柄,并对其进行修改以实现禁用效果。
4128

被折叠的 条评论
为什么被折叠?



