Solved

TRichEdit-problem

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now