谢谢!
5 个解决方案
#1
CEdit::LineScroll
void LineScroll( int nLines, int nChars = 0 );
Parameters
nLines
Specifies the number of lines to scroll vertically.
nChars
Specifies the number of character positions to scroll horizontally. This value is ignored if the edit control has either the ES_RIGHT or ES_CENTER style.
Remarks
Call this function to scroll the text of a multiple-line edit control.
This member function is processed only by multiple-line edit controls.
The edit control does not scroll vertically past the last line of text in the edit control. If the current line plus the number of lines specified by nLines exceeds the total number of lines in the edit control, the value is adjusted so that the last line of the edit control is scrolled to the top of the edit-control window.
void LineScroll( int nLines, int nChars = 0 );
Parameters
nLines
Specifies the number of lines to scroll vertically.
nChars
Specifies the number of character positions to scroll horizontally. This value is ignored if the edit control has either the ES_RIGHT or ES_CENTER style.
Remarks
Call this function to scroll the text of a multiple-line edit control.
This member function is processed only by multiple-line edit controls.
The edit control does not scroll vertically past the last line of text in the edit control. If the current line plus the number of lines specified by nLines exceeds the total number of lines in the edit control, the value is adjusted so that the last line of the edit control is scrolled to the top of the edit-control window.
#2
谢谢楼上,但是还是不能解决我的问题。
我的CEdit控件里显示的内容为 CString str, 我要选中的内容是 str 的第 m 个字符至第 n 个字符。我的CEdit控件为多行、自动换行(只有垂直滚动条没有水平滚动条)。因此,如果使用 LineScroll 的话,我不知道我所选中的内容在CEdit 控件中属于第几行!
我的CEdit控件里显示的内容为 CString str, 我要选中的内容是 str 的第 m 个字符至第 n 个字符。我的CEdit控件为多行、自动换行(只有垂直滚动条没有水平滚动条)。因此,如果使用 LineScroll 的话,我不知道我所选中的内容在CEdit 控件中属于第几行!
#3
CEdit::LineFromChar
int LineFromChar( int nIndex = -1 ) const;
Return Value
The zero-based line number of the line containing the character index specified by nIndex. If nIndex is –1, the number of the line that contains the first character of the selection is returned. If there is no selection, the current line number is returned.
Parameters
nIndex
Contains the zero-based index value for the desired character in the text of the edit control, or contains –1. If nIndex is –1, it specifies the current line, that is, the line that contains the caret.
Remarks
Call this function to retrieve the line number of the line that contains the specified character index. A character index is the number of characters from the beginning of the edit control.
int LineFromChar( int nIndex = -1 ) const;
Return Value
The zero-based line number of the line containing the character index specified by nIndex. If nIndex is –1, the number of the line that contains the first character of the selection is returned. If there is no selection, the current line number is returned.
Parameters
nIndex
Contains the zero-based index value for the desired character in the text of the edit control, or contains –1. If nIndex is –1, it specifies the current line, that is, the line that contains the caret.
Remarks
Call this function to retrieve the line number of the line that contains the specified character index. A character index is the number of characters from the beginning of the edit control.
#4
参考
m_Edit2.SetWindowText("adfvaedfvwrry\r\n" // 15
"sdfsdfbsdfjmy\r\n" // 30
"dsvsdfbsdfuio\r\n" // 45
"dcvsadvsddtgh\r\n" // 60
"dcvsadvsddtgh\r\n" // 75
"dasfvadvqqedf\r\n");// 90
m_Edit2.SetSel(75,76);
int sLine=m_Edit2.LineFromChar();
int fLine=m_Edit2.GetFirstVisibleLine();
m_Edit2.LineScroll(sLine - fLine);
#5
我在想,如果选中文字的宽度超过CEdit控件的宽度时咋办!
#1
CEdit::LineScroll
void LineScroll( int nLines, int nChars = 0 );
Parameters
nLines
Specifies the number of lines to scroll vertically.
nChars
Specifies the number of character positions to scroll horizontally. This value is ignored if the edit control has either the ES_RIGHT or ES_CENTER style.
Remarks
Call this function to scroll the text of a multiple-line edit control.
This member function is processed only by multiple-line edit controls.
The edit control does not scroll vertically past the last line of text in the edit control. If the current line plus the number of lines specified by nLines exceeds the total number of lines in the edit control, the value is adjusted so that the last line of the edit control is scrolled to the top of the edit-control window.
void LineScroll( int nLines, int nChars = 0 );
Parameters
nLines
Specifies the number of lines to scroll vertically.
nChars
Specifies the number of character positions to scroll horizontally. This value is ignored if the edit control has either the ES_RIGHT or ES_CENTER style.
Remarks
Call this function to scroll the text of a multiple-line edit control.
This member function is processed only by multiple-line edit controls.
The edit control does not scroll vertically past the last line of text in the edit control. If the current line plus the number of lines specified by nLines exceeds the total number of lines in the edit control, the value is adjusted so that the last line of the edit control is scrolled to the top of the edit-control window.
#2
谢谢楼上,但是还是不能解决我的问题。
我的CEdit控件里显示的内容为 CString str, 我要选中的内容是 str 的第 m 个字符至第 n 个字符。我的CEdit控件为多行、自动换行(只有垂直滚动条没有水平滚动条)。因此,如果使用 LineScroll 的话,我不知道我所选中的内容在CEdit 控件中属于第几行!
我的CEdit控件里显示的内容为 CString str, 我要选中的内容是 str 的第 m 个字符至第 n 个字符。我的CEdit控件为多行、自动换行(只有垂直滚动条没有水平滚动条)。因此,如果使用 LineScroll 的话,我不知道我所选中的内容在CEdit 控件中属于第几行!
#3
CEdit::LineFromChar
int LineFromChar( int nIndex = -1 ) const;
Return Value
The zero-based line number of the line containing the character index specified by nIndex. If nIndex is –1, the number of the line that contains the first character of the selection is returned. If there is no selection, the current line number is returned.
Parameters
nIndex
Contains the zero-based index value for the desired character in the text of the edit control, or contains –1. If nIndex is –1, it specifies the current line, that is, the line that contains the caret.
Remarks
Call this function to retrieve the line number of the line that contains the specified character index. A character index is the number of characters from the beginning of the edit control.
int LineFromChar( int nIndex = -1 ) const;
Return Value
The zero-based line number of the line containing the character index specified by nIndex. If nIndex is –1, the number of the line that contains the first character of the selection is returned. If there is no selection, the current line number is returned.
Parameters
nIndex
Contains the zero-based index value for the desired character in the text of the edit control, or contains –1. If nIndex is –1, it specifies the current line, that is, the line that contains the caret.
Remarks
Call this function to retrieve the line number of the line that contains the specified character index. A character index is the number of characters from the beginning of the edit control.
#4
参考
m_Edit2.SetWindowText("adfvaedfvwrry\r\n" // 15
"sdfsdfbsdfjmy\r\n" // 30
"dsvsdfbsdfuio\r\n" // 45
"dcvsadvsddtgh\r\n" // 60
"dcvsadvsddtgh\r\n" // 75
"dasfvadvqqedf\r\n");// 90
m_Edit2.SetSel(75,76);
int sLine=m_Edit2.LineFromChar();
int fLine=m_Edit2.GetFirstVisibleLine();
m_Edit2.LineScroll(sLine - fLine);
#5
我在想,如果选中文字的宽度超过CEdit控件的宽度时咋办!