Solved

TRichEdit-problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

21 Experts available now in Live!

Get 1:1 Help Now