Link to home
Start Free TrialLog in
Avatar of yuhoo
yuhoo

asked on

ListBox OnScroll

I need OnScrool event for list boxes. How to make it?

In fact I want two list boxes to be synchronized, ie when user scrolls through first, the second follows it automatically...
Avatar of BoRiS
BoRiS

yuhoo

You can use the GetScrollInfo and the SetScrollInfo API calls to synchronize the listboxs something like...

GetScrollinfo(Listbox1.Handle, SB_CTL, SIF_POS or SIF_RANGE or SIF_PAGE );

SetScrollinfo(Listbox2.Handle, SB_CTL, SIF_POS or SIF_RANGE or SIF_PAGE, True);

To create an OnScroll event you can try this...it's just an example I have not tested it so I'm not sure if it will work....

private
FOnScroll : TNotifyEvent;

protected
procedure CMScroll(var Message: TMessage); message CM_SCROLL;

published
property OnScroll: TNotifyEvent read FOnScroll write FOnScroll;

then the procedure...

procedure TListBoxEx.CMScroll(var Message: TMessage);
begin
  inherited;
    if Assigned (FOnScroll) then FOnScroll(Self);
end;

Later
BoRiS
hi
there is a component on delphi super page to do this.
http://sunsite.icm.edu.pl/delphi/

it's called something like hslistbox.zip
i not tried it myself but supposed to be ok.
Regards Barry
yuhoo

You can use the GetScrollInfo and the SetScrollInfo API calls to synchronize the listboxs something like...

GetScrollinfo(Listbox1.Handle, SB_CTL, SIF_POS or SIF_RANGE or SIF_PAGE );

SetScrollinfo(Listbox2.Handle, SB_CTL, SIF_POS or SIF_RANGE or SIF_PAGE, True);

To create an OnScroll event you can try this...it's just an example I have not tested it so I'm not sure if it will work....

private
FOnScroll : TNotifyEvent;

protected
procedure CMScroll(var Message: TMessage); message CM_SCROLL;

published
property OnScroll: TNotifyEvent read FOnScroll write FOnScroll;

then the procedure...

procedure TListBoxEx.CMScroll(var Message: TMessage);
begin
  inherited;
    if Assigned (FOnScroll) then FOnScroll(Self);
end;

Later
BoRiS
ASKER CERTIFIED SOLUTION
Avatar of earthworm
earthworm

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