Link to home
Start Free TrialLog in
Avatar of d_melnyk
d_melnykFlag for Canada

asked on

Determining position of horizontal scroll bar in a listbox

Hi Folks:

    I am trying to create an ActiveX component consisting of two listboxes. I need to be trap the position of the horizontal scrollbar in one of the listboxes so as to be able to then set the position of the horizontal scrollbar in the second listbox to match.

I have code which subclsses and traps the horizontal scroll bar event in the first listbox, but how can I determine its position and then update the position of the scrollbar in the second listbox?

I have been looking at GetScrollinfo / SetScrollinfo Win API calls, but simply including the declaration statements in the userControl seems to cause a VB 6.0 GPF fault - blows away VB6.0 environment!

Any assistance would be greatly appreciated.

Best regards, Dave Melnyk, Toronto
Avatar of jimbobmcgee
jimbobmcgee
Flag of United Kingdom of Great Britain and Northern Ireland image

I don't know about the scroll bars but, if the list boxes have an equal number of items, surely you can just set the SelectedItem value of one to the SelectedItem value of the other.

Or are you just trying to smoothly scroll both at the same time, without selection?

J.
ASKER CERTIFIED SOLUTION
Avatar of zzzzzooc
zzzzzooc

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
Avatar of Mike Tomlinson
That technique will work but you still have to subclass the form to get the Horizontal Scroll event since the List1_Scroll() event won't fire for horizontal movement.

~IM
Avatar of d_melnyk

ASKER

Jimbobmcgee:   Thanks for the reply. I am trying to scroll listboxes horizontally without selection.

zzzzz00c: Thanks for the reply and the sample code. Tried it with the few small changes for horizontal scrolling and it works great! Many thanks ... we have a winner!

Idle Mind: Thanks for the reply. I had mentioned in my question that I had found some subclassing code to trap the horizontal scroll event - found the  artical and sample code at www.devx.com/tips/Tip/5333 in case anyone else reading this is interested.

Many thanks to all who responded - you have helped me to keep my sanity intact.

Best regards, Dave Melnyk