Board index » cppbuilder » Setting the length of RichEdit->Line[x] function need to be called several times to sucseed...
Oren Halvani
![]() CBuilder Developer |
Setting the length of RichEdit->Line[x] function need to be called several times to sucseed...2004-03-01 06:13:53 AM cppbuilder22 hi dear builders, I found a strange bug in my application... I'm setting the length of each Line in RichEdit to (for example) "6" heres what I have: _________________________________ text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text OK, now here is the result: ________________________________ text t text t text t my function works for short text,but when I load a textfile with about 30 KByte, I need to call the function several times, or with other words (the user has to press the button several times) until I get the result that I need like above...why..? Is something went wrong with the for( ) loop: for(int x = 0; x < p->Lines->Count; ++x) can someone help..? Oren /*************************************************************/ void SetLinesLength(TRichEdit* p, int length) { Screen->Cursor = crHourGlass; try { p->Lines->BeginUpdate(); for(int x = 0; x < p->Lines->Count; ++x) if(p->Lines->Strings[x].Length()>length) { if(p->Lines->Strings[x][p->Lines->Strings[x].Length()] != '\r\n' ) { p->Lines->Strings[x] = p->Lines->Strings[x].SetLength(length); Application->ProcessMessages(); } else { p->Lines->Strings[x] = p->Lines->Strings[x].SetLength(length); Application->ProcessMessages(); } } } __finally { p->Lines->EndUpdate(); Screen->Cursor = crDefault; } } void __fastcall TfrmTextlaenge_setzen::Button1Click(TObject *Sender) { int i = StrToInt(Edit1->Text); SetLinesLength(Form2->RichEdit1, i); } |