Link to home
Start Free TrialLog in
Avatar of sorentop
sorentop

asked on

Scroll'ed down in memo

I want to now if a TMemo is scroll'ed to the bottom.
I try to use SBM_GETPOS to get the possition

a := Memo1.Perform(SBM_GETPOS, 0, 0);

but it always returns 0, probaly because I don't send the message to the scrollbar.
ASKER CERTIFIED SOLUTION
Avatar of Yunoshev
Yunoshev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use GetScrollInfo as shown below. Place two TMemo controls
on a form, place the code below in an event such as a
command button OnClick for instance and then scroll down or up to see the position by running the code. Hope this can help you.

Kevin


procedure TForm2.Button1Click(Sender: TObject);
var
  si: TScrollInfo ;
  dwError: DWORD ;
begin
  dwError := 0 ;
  si.fMask := SIF_ALL      ;
  si.cbsize := sizeof(si) ;
  if not GetScrollInfo(Memo1.Handle, SB_VERT, si) then
  begin
    dwError := GetLastError() ;
    Memo2.Clear ;
    Memo2.Lines.Add('Failed to get information') ;
  end else
  begin
    with Memo2 do
    begin
      Clear ;
      Lines.Add('min scrolling position ' + IntToStr(si.nMin)) ;
      Lines.Add('max scrolling position ' + IntToStr(si.nMax)) ;
      Lines.Add('scroll-box position ' + IntToStr(si.nPos )) ;  { This is it }
    end ;
  end ;
end;
Avatar of sorentop
sorentop

ASKER

The -1 should be removed