CEdit::LineLength无法正确获得字符数( 看到别人的问题),于是自己测试了函数linelength,结果发现linegth却是无法正确获得字符数edit是个多行的属性,我已经勾选了风格和接受回车的属性
即:
EDITTEXT IDC_EDIT1,51,29,98,30,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN
测试的时候输入的内容为:
dd
dvoid Ctesst33Dlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
// TODO: 在此添加控件通知处理程序代码
int n=m_edit.LineLength(10); //n为1
}
而msdn:CEdit::LineLengthVisual Studio 2008 Other Versions 0 out of 2 rated this helpful - Rate this topic
Updated: September 2008
Retrieves the length of a line in an edit control.
int LineLength(
int nLine = -1
) const;
Parameters
nLine
The zero-based index of a character in the line whose length is to be retrieved. The default value is -1.
Return Value
For single-line edit controls, the return value is the length, in TCHARs, of the text in the edit control.
For multiline edit controls, the return value is the length, in TCHARs, of the line specified by the nLine parameter. For ANSI text, the length is the number of bytes in the line; for Unicode text, the length is the number of characters in the line. The length does not include the carriage-return character at the end of the line.
If the nLine parameter is more than the number of characters in the control, the return value is zero.
If the nLine parameter is –1, the return value is the number of unselected characters in the lines that contain selected characters. For example, if the selection extends from the fourth character of one line through the eighth character from the end of the next line, the return value is 10. That is, three characters on the first line and seven on the next.
For more information about the TCHAR type, see the TCHAR row in the table in Windows Data Types.
解决方案 »
- MFC ActiveX中如何同时绘两路视频, 并相互不影响?
- UDP代理中如何获得目的地址
- DeviceIoControl获取分区表的个数为0,为什么?
- 初学COM,一个实例问题,请大家指点一下,在线等
- 难道真的微软的东西就不如SUN
- 求window2003下服务(Service)程序中显示对话框的例子
- 请求帮助:哪里能找到各种Window消息(WM_XXXXX)的详尽解释啊?
- ***在打包时遇到的问题,请求各位帮助***
- 两个程序之间如何通信(等待中)
- 对话框问题,猛将往这里看呀!
- 公共DC,在GetDC之后,需要ReleaseDC吗?为什么我不写ReleaseDC,对程序没有任何影响的?
- bho劫持困惑,来自百度搜索结果!
特意翻看了 widnows程序上的 em_linelength这个消息的用法 :sendmessage(句柄,em_linelength,iline,0);就说了这么一句。其他没有说
多谢