Thanx Tony
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.
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!