Board index » delphi » Scrolling a RichEdit programatically

Scrolling a RichEdit programatically

Is there a way to scroll a RichEdit programmatically? My program
searches for phrases and I want to scroll the RichEdit so that the
phrase is in the middle of the screen.(I know how to find the line in
which it occurs). ScrollBy doesn't do what I want, and placing the
RichEdit in  a scrollbox has its problems.

 

Re:Scrolling a RichEdit programatically


Quote
Tore Ottinsen wrote:

> Is there a way to scroll a RichEdit programmatically? My program
> searches for phrases and I want to scroll the RichEdit so that the
> phrase is in the middle of the screen.(I know how to find the line in
> which it occurs). ScrollBy doesn't do what I want, and placing the
> RichEdit in  a scrollbox has its problems.

Try setting the SelStart property.

Anders Blaagaard (b...@ifad.dk)

Re:Scrolling a RichEdit programatically


Quote
Anders Blaagaard wrote:
> Tore Ottinsen wrote:

> > Is there a way to scroll a RichEdit programmatically? My program
> > searches for phrases and I want to scroll the RichEdit so that the
> > phrase is in the middle of the screen.(I know how to find the line in
> > which it occurs). ScrollBy doesn't do what I want, and placing the
> > RichEdit in  a scrollbox has its problems.

> Try setting the SelStart property.

No, SelStart doesn't scroll the control. I would think a message is
needed.

Re:Scrolling a RichEdit programatically


Quote
In article <35583330.45E5E...@ifad.dk>, Anders Blaagaard <b...@ifad.dk> writes:
>> Is there a way to scroll a RichEdit programmatically? My program
>> searches for phrases and I want to scroll the RichEdit so that the
>> phrase is in the middle of the screen.(I know how to find the line in
>> which it occurs). ScrollBy doesn't do what I want, and placing the
>> RichEdit in  a scrollbox has its problems.

RichEdit1.Perform(EM_LineScroll, 0, RichEdit1.Lines.Count * -1); {moves to top}
VOffset := RichEdit1.Height div (RichEdit1.Font.Height * -2);
RichEdit1.Perform(EM_LineScroll, 0, LineToGoTo - VOffset); {puts line in the
middle (vertically) of RichEdit}

Alan Lloyd
alangll...@aol.com

Re:Scrolling a RichEdit programatically


I think all you need is to select the phrase using SelStart and SelLength
properties next send EM_SCROLLCARET message to your control:

  RichEdit1.Perform(EM_SCROLLCARET,0,0);

Hope this helps.
Alexander Demsky.

In article <3558280B.51080...@hellerud.vgs.no>,

Quote
  tor...@hellerud.vgs.no wrote:

> Is there a way to scroll a RichEdit programmatically? My program
> searches for phrases and I want to scroll the RichEdit so that the
> phrase is in the middle of the screen.(I know how to find the line in
> which it occurs). ScrollBy doesn't do what I want, and placing the
> RichEdit in  a scrollbox has its problems.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading

Re:Scrolling a RichEdit programatically


Quote
Tore Ottinsen wrote in message <3558280B.51080...@hellerud.vgs.no>...
>Is there a way to scroll a RichEdit programmatically? My program
>searches for phrases and I want to scroll the RichEdit so that the
>phrase is in the middle of the screen.(I know how to find the line in
>which it occurs). ScrollBy doesn't do what I want, and placing the
>RichEdit in  a scrollbox has its problems.

On a similar vein...
How can you get the value of the scroller's position and is there an event
when a scroller is scrolled?
I am trying to implement a ruler for a RichEdit but when the RichEdit is
scrolled I need to move the origin of the ruler (displayed on a panel) as
well.

Regards,
David Taylor

www.solarsys.co.uk

Re:Scrolling a RichEdit programatically


On 12 May 1998 16:18:37 GMT, alangll...@aol.com (AlanGLLoyd) wrote:

Many thanks, that also solves the same problem with memo fields.  Is
there some section of the Delphi documentation which deals with
trickery like that or gives a rundown of the major uses of the Perform
method?  The problem is that without finding something like your
explaination on the net, I don't know where I'd normally go to find
these kinds of oddball usages which are totally essential to using the
product.

Ted Holden
med...@access.digex.com

Quote
>RichEdit1.Perform(EM_LineScroll, 0, RichEdit1.Lines.Count * -1); {moves to top}
>VOffset := RichEdit1.Height div (RichEdit1.Font.Height * -2);
>RichEdit1.Perform(EM_LineScroll, 0, LineToGoTo - VOffset); {puts line in the
>middle (vertically) of RichEdit}

>Alan Lloyd
>alangll...@aol.com

Other Threads