BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tmemo caret position again

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
YAZ
Guest





PostPosted: Fri Feb 17, 2006 7:03 pm    Post subject: Tmemo caret position again Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.