Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hooks into scroll bars

95 views
Skip to first unread message

Gambler

unread,
Aug 5, 1998, 3:00:00 AM8/5/98
to
Is there a way to easily hook into the TMemo scroll bars.... or how do we
identify the positions of the thumbtabs on the scroll bars and how to
manipulate them through code?

Thanx Tony

Mark Bracey

unread,
Aug 5, 1998, 3:00:00 AM8/5/98
to Gambler
SetScrollPos(Handle,TYPE,POSITION,REDRAW);

Handle is the handle of the window. Look up SetScrollPos in the WIN32
online help. There are other routines for getting the posiition, like
SetScrollInfo for example.

Peter Below

unread,
Aug 6, 1998, 3:00:00 AM8/6/98
to
> Is there a way to easily hook into the TMemo scroll bars.... or how do we
> identify the positions of the thumbtabs on the scroll bars and how to
> manipulate them through code?
>
Tony,

since a TMemo already handles the scrollbar internally you should use the
messages it understands to interact with it, directly messing with scroll
messages (WM_VSCROLL) and the scrollbar (SetScrollInfo) will only conflict
with the control.

To inquire about the line the caret is in, use EM_LINEFROMCHAR:

Row := Memo1.PerForm(EM_LINEFROMCHAR,Memo1.SelStart,0);
Col := Memo1.SelStart-Memo1.Perform(EM_LINEINDEX,Row,0);

To get the first line in the display, use EM_GETFIRSTVISIBLELINE:

firstline := Memo1.Perform( EM_GETFIRSTVISIBLELINE, 0, 0 );

To induce the memo to scroll, send it EM_LINESCROLL messages (see
win32.hlp for details).

If you need to get notified when the user scrolls the control you have to
derive a new class from TMemo, and add a handler for the CN_COMMAND
message. This is a VCL message Delphi uses to "echo" notification messages
the control sends to its parent in the form of WM_COMMAND messages back to
the control. In the handler you look for EN_VSCROLL or EN_HSCROLL
notifications; you can use them to fire a custom OnVScroll or OnHScroll
event.

There are lot of examples for CN_Command handlers in the VCL code, e.g. in
the stdctrls Unit.

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitely requested!


0 new messages