Solved

TRichEdit-problem

Posted on 1997-08-13
5
292 Views
Last Modified: 2010-04-06
Hi.

Sorry, I dont have any more points. If you know a good answer to my question please notify my and i will by some points to give you!!!!! Thanx.

I have a TRichEdit (RichEdit1) that I load large files into. I want to examin if the format of these files are correct. I do that by running through the file line by line.
My problem is that...

var
  St1 : string;
begin
  St1 := RichEdit1.Lines[no];
...

...takes more and more time as no gets higher. I work with very large files and the time used on the formatchecking is just to long. I have tried to use the Text-property and some pointer-gym. istead (having a pointer pointing to the beginning of the next line and just create the string from the pointer) and that worked fine in the beginning, but the i got in some problems doing that (Very, very, very strange problems).
Now i want to know if any of you guys know how to work around my problem (Reading through all the lines of a large TRichEdit, without using alot of time)?
Anyone one know of a desant of TRichEdit that might have some functionality that I could use?

Thanx - Steff
0
Comment
Question by:steff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:mirek071497
ID: 1341312
TRichEdit (Delphi2) don't have TEXT property and lines is TStrings so works very fast. You can't made this faster.
p.s. You can buy some point's
0
 

Author Comment

by:steff
ID: 1341313
I have Delphi2 and I also have a Text-property to work with. I might have a older version of Delphi2????
If you know any way for me to get this fast TRichEdit I would realy like to know!

Thanx - Steff
0
 

Author Comment

by:steff
ID: 1341314
Adjusted points to 30
0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 30 total points
ID: 1341315
Hi Stef.

Ok. When You send me example i just know what you need. TRich edit have'nt Text property but you can retrive the text with send message.


{ Here is stupid example but i think so this can help you }

....
{declaration's}
....

uses
  RichEdit, ....{other unit's}  ;

procedure AnyName;
var
  L: Integer;
  TextRange : TTextRange;
  i,k : integer;
  st : string;
begin
  TextRange.chrg.cpMin := 0;
  TextRange.chrg.cpMax := 10239;
  GetMem( TextRange.lpStrText, 10240 );
  L := SendMessage(RichEdit1.Handle, EM_GETTEXTRANGE, 0, Longint(@TextRange));
  for i:=1 to (l div 10) do
  begin
    st := '';
    for k:=1 to 10 do
      st := st + TextRange.lpStrText[10*(i-1)+k-1];
    Memo1.Lines.Add(st);
  end;
  FreeMem( TextRange.lpStrText, 10240 );
end;


TTextRange structure is defined in RichEdit.Pas unit and Win32.HLP describes more about TRichEdit control.

type
  TCharRange = record
    cpMin: Longint;         { number of first char to retrieve }
    cpMax: LongInt;        { number of last char to retrieve }
  end;

  TTextRange = record
    chrg: TCharRange;
    lpstrText: PChar;      { buffer where data will be copied }
  end;

Mirek
0
 

Author Comment

by:steff
ID: 1341316
OK! Thanx alot.

I will see what I can use your answer for. If I have a few more questions conserning the same matter I hope you will accept me sending you a e-mail about it.

Thanx again - Steff
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mobile Keyboard covers the display of the TMemo 3 113
Downloading email attachments 2 93
Adoquery sql  left join does not work 25 117
Convert MS Word document to a PDF file 9 131
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question