?
Solved

ListBox OnScroll

Posted on 1999-01-25
4
Medium Priority
?
1,368 Views
Last Modified: 2012-06-27
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...
0
Comment
Question by:yuhoo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:BoRiS
ID: 1363331
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
0
 
LVL 17

Expert Comment

by:inthe
ID: 1363332
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
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1363333
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
0
 

Accepted Solution

by:
earthworm earned 200 total points
ID: 1363334
It's a good idea to process the Scoll message,but if you don't want to write a new component,you can try this:
you can set the property "Style" of the listbox to "lbOwnerDrawFixed",so the ListBox wil occur the "OnDrawItem" Even when it be scrolled and you can Synchronized the listbox on this event, BUT YOU MUST DRAW THE ITEMS IN THE LISTBOX YOURSELF,SORRY.

by the way, you can synchronize the listboxes by this way:
  ListBox2.TopIndex:=ListBox1.TopIndex;
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question