win32 设置Edit控件为只读

使用CreateWindow创建了Edit控件后,想把该控件设置成只读,就可以使用:

::PostMessageW(hwnd, EM_SETREADONLY, 1, 0);发送这个消息到Edit控件后,就可以设置成只读属性。具体介绍情况下面的MSDN:


EM_SETREADONLY Message


The EM_SETREADONLY message sets or removes the read-only style (ES_READONLY) of an edit control. You can send this message to either an edit control or a rich edit control.

Syntax

To send this message, call the SendMessage function as follows.
 
  
lResult=SendMessage(//returnsLRESULTinlResult
(HWND) hWndControl,// handle to destination control
(UINT) EM_SETREADONLY,// message ID
(WPARAM)wParam,//=(WPARAM)()wParam;
(LPARAM)lParam//=0;notused,mustbezero
);

Parameters

wParam
Specifies whether to set or remove the ES_READONLY style. A value of TRUE sets the ES_READONLY style; a value of FALSE removes the ES_READONLY style.
lParam
This parameter is not used.

Return Value

If the operation succeeds, the return value is nonzero.

If the operation fails, the return value is zero.


Remarks

When an edit control has the ES_READONLY style, the user cannot change the text within the edit control.

To determine whether an edit control has the ES_READONLY style, use the GetWindowLong function with the GWL_STYLE flag.

Rich Edit: Supported in Microsoft Rich Edit 1.0 and later. For information about the compatibility of rich edit versions with the various system versions, see About Rich Edit Controls.

MessageInformation

HeaderDeclared in Winuser.h, include Windows.h
Minimum operating systemsWindows95, Windows NT3.1

See Also

Edit Controls Overview, GetWindowLong



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值