MFC——EDIT空间显示内容大小限制在32K,如何解除?
1. 问题
MFC之EDIT控件显示只能32k,再多就不显示了,除非清空;
2. 原因
MFC默认情况下edit是32K, richedit是64K。
3. 解决
CEdit* pEdit = (CEdit *)GetDlgItem(IDC_EDIT_GET); pEdit->LimitText(-1); //创建后加上这句即可 int l = pEdit->GetWindowTextLength(); pEdit->SetSel(l,l,FALSE); pEdit->SetFocus();//光标最后一行 pEdit->ReplaceSel(DisTmp); //新接收的数据,接着显示
The EM_LIMITTEXT message limits only the text the user can enter. It does not affect any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control by the WM_SETTEXT message. If an application uses the WM_SETTEXT message to place more text into an edit control than is specified in the EM_LIMITTEXT message, the user can edit the entire contents of the edit control. Before EM_LIMITTEXT is called, the default limit for the amount of text a user can enter in an edit control is 32,767 characters. Edit controls on Windows NT/2000/XP: For single-line edit controls, the text limit is either 0x7FFFFFFE bytes or the value of the wParam parameter, whichever is smaller. For multiline edit controls, this value is either –1 bytes or the value of the wParam parameter, whichever is smaller. Edit controls on Windows 95/98/Me: For single-line edit controls, the text limit is either 0x7FFE bytes or the value of the wParam parameter, whichever is smaller. For multiline edit controls, this value is either 0xFFFF bytes or the value of the wParam parameter, whichever is smaller. Rich Edit: Supported in Rich Edit 1.0 and later. Use the message EM_EXLIMITTEXT for text length values greater than 64K. For information about the compatibility of rich edit versions with the various system versions, see About Rich Edit Controls.
