Win 32 API 怎么设置文本框为不可输入

 我来答
GetSafeHwnd
2017-01-31 · TA获得超过918个赞
知道大有可为答主
回答量:1068
采纳率:76%
帮助的人:749万
展开全部
方法一 设置 edit控件 style 具有 ES_READONLY (createwindow的时候加上)
已经创建要控件的 发消息 EM_SETREADONLY
EM_SETREADONLY

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.

To send this message, call the SendMessage function with the following
parameters.
SendMessage(
(HWND) hWnd, // handle to destination window
EM_SETREADONLY, // message to send
(WPARAM) wParam, // read-only option
(LPARAM) lParam // not used; must be zero
);

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 Values

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: For information about the compatibility of rich edit
versions with the various system versions, see About
Rich Edit Controls
方法二 直接使之变灰禁用,EnableWindow(文本框句柄,False)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式