CEdit控件最大长度? (可以显示的字符) [英] CEdit control maximum length? (in characters it can display)

查看:4645
本文介绍了CEdit控件最大长度? (可以显示的字符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MFC中的CEdit控件中包含的文本字符串的最大长度是多少?我试图在字符30001之后添加字符时发出嘟嘟声吗?我可以在CEdit中显示更长的文本吗?

What is the maximum length for the text string contained in a CEdit control in MFC? I get a beep when trying to add a character after the character 30001 is this documented anywhere? Can I display longer texts in a CEdit? Should I use another control?

由于Windows程序员在下面说明,当用户输入时,文本长度限制不同,当我们编程设置文本时SetWindowText。在任何地方都没有提到编程设置文本的限制。用户输入的默认文本lentgth限制是错误的。 (见我自己的帖子下面)。

As "Windows programmer" says down below, the text length limit is not the same when the user types as when we programatically set the text using SetWindowText. The limit for setting a text programatically is not mentioned anywhere. The default text lentgth limit for the user typing is wrong. (see my own post below).

我猜我调用pEdit-> SetLimitText(0)后,程序和用户输入文本长度的限制是7FFFFFFE字节。

I'm guessing that after I call pEdit->SetLimitText(0) the limit for both programatically and user input text length is 7FFFFFFE bytes. Am I right?

在vista中,当将超过40000个字符的文本粘贴到CEdit中时,它会变得无响应。如果我之前调用SetLimitText(100000)没关系。

In vista, when pasting text longer than 40000 characters into a CEdit, it becomes unresponsive. It does not matter if I called SetLimitText(100000) previously.

推荐答案

我发现文档是错误的,

I found the documentation is wrong when mentioning the default size for a single line CEdit control in vista.

我运行此代码:

CWnd* pWnd = dlg.GetDlgItem(nItemId);
CEdit *edit = static_cast<CEdit*>(pWnd); //dynamic_cast does not work
if(edit != 0)
{
    UINT limit = edit->GetLimitText(); //The current text limit, in bytes, for this CEdit object.
    //value returned: 30000 (0x7530)
    edit->SetLimitText(0);
    limit = edit->GetLimitText();
    //value returned: 2147483646 (0x7FFFFFFE) 
}



<

the documentation states:


在调用EM_SETLIMITTEXT之前,
默认限制文本的数量a
用户可以在编辑控制是
32,767个字符。

Before EM_SETLIMITTEXT is called, the default limit for the amount of text a user can enter in an edit control is 32,767 characters.

这显然是错误的。

这篇关于CEdit控件最大长度? (可以显示的字符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆