 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
YAZ Guest
|
Posted: Fri Feb 17, 2006 7:03 pm Post subject: Tmemo caret position again |
|
|
Hello,
I noticed that a Tmemo changes the way it adds the text according to
the caret position.
here are my examples :
void __fastcall TForm1::btn1Click(TObject *Sender)
{
Memo1->SelStart=MaxInt; // go to End
Memo1->Lines->Add("Memo1->Lines->Add»");
Memo1->SelStart=MaxInt;
AnsiString stat = "(" + AnsiString(Memo1->CaretPos.y) +
","+ AnsiString(Memo1->CaretPos.x) +")";
StatusBar1->Panels->Items[0]->Text=stat;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btn2Click(TObject *Sender)
{
//
Memo1->SelStart=MaxInt;
int index = (Memo1->Lines->Count -1 );
AnsiString str = Memo1->Lines->Strings[index];
Memo1->Lines->Strings[index] = (str +
"Memo1->Lines->Strings[index]»");
Memo1->SelStart=MaxInt;
AnsiString stat = "(" + AnsiString(Memo1->CaretPos.y) +
","+ AnsiString(Memo1->CaretPos.x) +")";
StatusBar1->Panels->Items[0]->Text=stat;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btn3Click(TObject *Sender)
{
//
Memo1->SelStart=MaxInt;
Memo1->Text = Memo1->Text + "Memo1->Text= Memo1->Text + »";
Memo1->SelStart=MaxInt;
AnsiString stat = "(" + AnsiString(Memo1->CaretPos.y) +
","+ AnsiString(Memo1->CaretPos.x) +")";
StatusBar1->Panels->Items[0]->Text=stat;
}
//---------------------------------------
I noticed that :
1- if the last line is empty (CaretPos.y =0) then btn1Click add the
text on a new line et the caret go to a new line behind the added line.
Why ? is there a way to correct this ?
2- if the last line is empty then btn2Click add the text the previous
line and the caret stay on the last empty line.
3- btn3Click works as expected in all the situations.
I suupose the btn3Click is slower than btn2Click because it modifies
all text of the memo while btn2Click modifies only the desired line.
right ?
What the fatest way to add text to a memo ?
thank you |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|