- 第一种方法,用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.