VC中,对话框置灰

禁用关闭菜单项
本文介绍了两种禁用窗口菜单中关闭选项的方法。一种是通过使用 ModifyMenu 函数,另一种则是利用 EnableMenuItem 函数。这两种方法都需要获取窗口菜单句柄,并对其进行修改以实现禁用效果。
  1. 第一种方法,用ModiftMenu()涵数来实现:
  2. CMenu* pMenu = this->GetSystemMenu(FALSE);
  3. pMenu->ModifyMenu(SC_CLOSE,MF_BYCOMMAND | MF_GRAYED );
  4. 第二种方法,用EnableMenuItem()涵数来实现:
  5. CMenu* pMenu = this->GetSystemMenu(FALSE);
  6. 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值