CEdit控件最大长度? (可以显示的字符)
MFC 中 CEdit 控件中包含的文本字符串的最大长度是多少? 当我尝试在字符 30001 之后添加字符时,我听到蜂鸣声,这是否记录在任何地方? 我可以在 CEdit 中显示更长的文本吗? 我应该使用其他控件吗?
正如“Windows 程序员”在下面所说,用户键入时的文本长度限制与我们使用 SetWindowText 以编程方式设置文本时的文本长度限制不同。 任何地方都没有提到以编程方式设置文本的限制。 用户输入的默认文本长度限制是错误的。 (请参阅下面我自己的帖子)。
我猜测在调用 pEdit->SetLimitText(0) 后,编程方式和用户输入文本长度的限制都是 7FFFFFFE 字节。 我对吗?
在 vista 中,当将超过 40000 个字符的文本粘贴到 CEdit 中时,它会变得无响应。 如果我之前调用过 SetLimitText(100000) 也没关系。
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?
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).
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?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现文档中提到 vista 中单行 CEdit 控件的默认大小时是错误的。
我运行了这段代码:
文档指出:
这显然是错误的。
I found the documentation is wrong when mentioning the default size for a single line CEdit control in vista.
I ran this code:
the documentation states:
which is apparently wrong.
您可以通过调用 CEdit 来了解您的控件的最大值是多少::GetLimitText() 在您的控件上。 这将返回字符数据的最大大小(以字节为单位)。 您可以使用 CEdit::SetLimitText() 更改最大大小 函数。
SetLimitText() 函数相当于发送 EM_SETLIMITTEXT 消息。 该消息的文档给出了可以使用的最大大小,但由于这些 MSDN 链接可能会在明天被破坏,所以我将复制相关信息:)
UINT 参数解释为:
另外,从备注部分:
我认为他们的意思是 0xFFFFFFFF 而不是第二段中的 -1 ......
You can find out what the maximum is for your control by calling CEdit::GetLimitText() on your control. This returns the maximum size for character data in bytes. You can change the maximum size using the CEdit::SetLimitText() function.
The SetLimitText() function is equivalent to sending an EM_SETLIMITTEXT message. The documentation for that message gives the maximum sizes that can be used, but since these are MSDN links that will probably be broken by tomorrow, I'll copy the relevant information :)
The UINT parameter is interpreted as:
Also, from the Remarks section:
I assume they meant 0xFFFFFFFF instead of -1 in the second paragraph there...
“(可以显示的字符)” != “尝试添加字符时”。
"尝试添加字符时" == "用户可以输入的最大 TCHAR 数"
除非您的意思是以编程方式尝试添加字符。
"0x7FFFFFFE 字符" != "0x7FFFFFFE 字节"
除了有时,引用的 MSDN 文本有时可以理解这一事实。
我敢打赌没有人知道最初问题的答案。 但“0x7FFFFFFE 字节”可能是众多限制之一。
"(in characters it can display)" != "when trying to add a character".
"when trying to add a character" == "The maximum number of TCHARs the user can enter"
unless you mean programmatically trying to add a character.
"0x7FFFFFFE characters" != "0x7FFFFFFE bytes"
except sometimes, a fact which the quoted MSDN text understands sometimes.
I'll bet no one knows the answer to the original question. But "0x7FFFFFFE bytes" is likely one of many limits.