C&C++论坛精华
源代码在线查看: 在richedit中如何将光标移动到指定的行?(转载).txt
作者:hxfwsk
email: hxfwsk@hotmail.com
日期:2001-6-18 14:55:40
在RichEdit中如何将光标移动到指定的行?(转载)
void __fastcall TRichEditTerm::SetCursor(int ARow, int ACol)
{//ARow and ACol start from 0
int i,j,iSelStart;
AnsiString as;
if(ARow ARow=0;
if(ACol ACol=0;
iSelStart=0;
if(ARow>Lines->Count-1)
{//Require add lines
j=ARow-Lines->Count+1;
for(i=1;i Lines->Add("");
for(i=0;i iSelStart+=Lines->Strings[i].Length()+2;
i=Text.Length();
}
else if(ARowCount-1)
{
for(i=0;i iSelStart+=Lines->Strings[i].Length()+2;
}
j=Lines->Strings[ARow].Length();
if(j {
as=Lines->Strings[ARow];
for(i=0;i as.Insert(" ",j+1);
Lines->Strings[ARow]=as;
}
SelStart=iSelStart+ACol;
SendMessage(Handle,EM_SCROLLCARET,0,0);
}