Board index » delphi » TRichEdit/TMemo Display Lines

TRichEdit/TMemo Display Lines

Does anyone know a universal way to determine the number of lines being
"displayed" in a multi-line edit control, or at least the line number of the
last displayed line?  I would like to have a function that requires that I
know this information.

Thanks.

 

Re:TRichEdit/TMemo Display Lines


Quote
>_TPietrzakPinnnacle wrote:

>Does anyone know a universal way to determine the number of lines being
>"displayed" in a multi-line edit control, or at least the line number >of the last displayed line?  I would like to have a function that

var
  R: TRect;
  lastvisibleline, lastlineindex: Integer;
Begin
  Memo1.Perform(EM_GETRECT, 0, longint(@R));
  lastlineindex := Memo1.Perform(EM_CHARFROMPOS, 0,
                                 MakeLParam(R.Left +1, R.Bottom -2));
  lastvisibleline := Memo1.Perform(EM_LINEFROMCHAR, lastlineindex, 0);

Note: returns the bottom line that is at least partly visible.
[originally posted by Peter Below]
________
Andreas
Delphi 5.01 Pro, NT4.0 Sp5
Direct replies mailto:p...@augsburg.netsurf.de

Re:TRichEdit/TMemo Display Lines


As we enter into a brand new year/decade/century/millenium, I just want to
say that getting responses to questions that are asked on this newsgroups,
in the professional manor in which they are given... is the reason that
Delphi will remain a "developer's"  tool of choice for the foreseeable
future.

Thank you to all that respond!  You input is always appreciated.

Tom Pietrzak.

Re:TRichEdit/TMemo Display Lines


Unfortunealy, this just returns back the number of elements in the controls
lines property.  I will look a bit deeper, but this doesn't give me what I
needed.

Quote
Andreas Pawlik wrote in message <3A4BCE50.9FBAD...@augsburg.netsurf.de>...
>>_TPietrzakPinnnacle wrote:

>>Does anyone know a universal way to determine the number of lines being
>>"displayed" in a multi-line edit control, or at least the line number >of

the last displayed line?  I would like to have a function that
Quote

>var
>  R: TRect;
>  lastvisibleline, lastlineindex: Integer;
>Begin
>  Memo1.Perform(EM_GETRECT, 0, longint(@R));
>  lastlineindex := Memo1.Perform(EM_CHARFROMPOS, 0,
>                                 MakeLParam(R.Left +1, R.Bottom -2));
>  lastvisibleline := Memo1.Perform(EM_LINEFROMCHAR, lastlineindex, 0);

>Note: returns the bottom line that is at least partly visible.
>[originally posted by Peter Below]
>________
>Andreas
>Delphi 5.01 Pro, NT4.0 Sp5
>Direct replies mailto:p...@augsburg.netsurf.de

Re:TRichEdit/TMemo Display Lines


The solution is to make the lastLineIndex a variable of type word, instead
of type integer.

Other Threads