Solved

TRichEdit-problem

Posted on 1997-08-13
5
289 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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

830 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