Board index » kylix » How to scroll to a specific location in a TMemo

How to scroll to a specific location in a TMemo


2005-07-15 07:12:36 AM
kylix2
So I know how to do this in Delphi/CBuilder but I can't seem to find a way to do this in Kylix.
In Delphi the following code would make a TMemo scroll to a specific location, in this case the 5th line from the top.
with Memo1 do
begin
SelStart := Perform(EM_LINEINDEX, 5, 0);
Perform(EM_SCROLLCARET, 0, 0);
end;
In Kylix TMemo.Perform doesn't exist. Any suggestions on how to do this would be appriciatied.
 
 

Re:How to scroll to a specific location in a TMemo

Jim K schrieb:
Quote
So I know how to do this in Delphi/CBuilder but I can't seem to find a way to do this in Kylix.

In Delphi the following code would make a TMemo scroll to a specific location, in this case the 5th line from the top.
with Memo1 do
begin
SelStart := Perform(EM_LINEINDEX, 5, 0);
Perform(EM_SCROLLCARET, 0, 0);
end;

In Kylix TMemo.Perform doesn't exist. Any suggestions on how to do this would be appriciatied.

You might try:
var Cp:TCaretPos;
...
Cp.Col:=0;
Cp.Line:=5;
SampleMemo.CaretPos:=Cp;
This ensures that the cursor position is visible.
Or you might take a TSynEdit (or TSynMemo) for more control. (see
Topline property)
 

Re:How to scroll to a specific location in a TMemo

Changing the CaretPos works but if the file is too large the performance can be pretty bad. I'll look into the TSynMemo and thanks for the tip.
Jim
theo < XXXX@XXXXX.COM >wrote:
Quote
Jim K schrieb:
>So I know how to do this in Delphi/CBuilder but I can't seem to find a way to do this in Kylix.
>
>In Delphi the following code would make a TMemo scroll to a specific location, in this case the 5th line from the top.
>with Memo1 do
>begin
>SelStart := Perform(EM_LINEINDEX, 5, 0);
>Perform(EM_SCROLLCARET, 0, 0);
>end;
>
>In Kylix TMemo.Perform doesn't exist. Any suggestions on how to do this would be appriciatied.
>

You might try:

var Cp:TCaretPos;

...

Cp.Col:=0;
Cp.Line:=5;
SampleMemo.CaretPos:=Cp;

This ensures that the cursor position is visible.

Or you might take a TSynEdit (or TSynMemo) for more control. (see
Topline property)
 

{smallsort}