473,386 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Horizontal Scrollbar

Hi all you Experts,
I need to scroll a listbox horizontally.
For the life of me I cannot get it to move. I can successfully scroll
it vertically.
I have the handle for the listbox and the scroll bar.
I have even tried sending it vbKeyRight to no avail, but it doesn't
register the key strokes.

I am using
lDirection = WM_HSCROLL
lThumb = MakeDWord(SB_THUMBPOSITION, CInt(lIndex))
SendMessage hwReportList, lDirection, lThumb, hwScrollBar

Is there anything else I can try? Am I missing something?
Thanks

Private Function MakeDWord(loword As Integer, hiword As Integer) As
Long
'************************************************* **********
' Here's the MakeDWord function from the MS KB
'************************************************* **********
On Error Resume Next
MakeDWord = (hiword * &H10000) Or (loword And &HFFFF&)
End Function

Dec 20 '05 #1
7 9329
Can you just make the listbox longer? I know that's not the best
option, but it's the laziest :) It's also guaranteed to work if your
data is usually about the same length. Not very technical, but easy to
implement.

Dec 20 '05 #2
Thanks Steve,
I wish I could, but the form width is not something I can't change so
I'm stuck with the list width I have too.

Dec 20 '05 #3
There's sample code on my site here:
http://www.lebans.com/setgetsb.htm
SetGetSB.zip is a database containing functions to allow a user to Set or
Get the current position of a ScrollBar Thumb for a Form.

NEW - Apr. 02/2000 The current ScrollBar position is equal to the current
Record Number being displayed at the Top of the Form.

Works in Form or Datasheet view.

Ver 1.7

Fix bug in SelTop method. Now works with first page of rows properly and
sets the Top row correctly when moving forward in the recordset one row at a
time.

Ver 1.6

Use SelTop to save Restore current row's position after a Requery.

Ver 1.5

Added support for Horizontal ScrollBars.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Pachydermitis" <pr*******@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Hi all you Experts,
I need to scroll a listbox horizontally.
For the life of me I cannot get it to move. I can successfully scroll
it vertically.
I have the handle for the listbox and the scroll bar.
I have even tried sending it vbKeyRight to no avail, but it doesn't
register the key strokes.

I am using
lDirection = WM_HSCROLL
lThumb = MakeDWord(SB_THUMBPOSITION, CInt(lIndex))
SendMessage hwReportList, lDirection, lThumb, hwScrollBar

Is there anything else I can try? Am I missing something?
Thanks

Private Function MakeDWord(loword As Integer, hiword As Integer) As
Long
'************************************************* **********
' Here's the MakeDWord function from the MS KB
'************************************************* **********
On Error Resume Next
MakeDWord = (hiword * &H10000) Or (loword And &HFFFF&)
End Function

Dec 20 '05 #4
Thanks Stephen,
I actually downloaded that and tried your methodology (slightly
modified of course) on my list box a couple days ago - to no avail.
Your solution is pretty slick. Thanks for making that available to
everyone.
Were you able to get a listbox to scroll horizontally?

Dec 20 '05 #5
Oh...you're working with a ListBox not a Form's ScrollBar. Sorry about
that.One is a control and the other is not if I remember correctly.

Have you tried changing the code on my site to work with a Horizontal
Scrollbar?

Method #2

Here's the code to force a ListBox to Scroll to a specific row. I put it
behind a Command Button Named Customer, you can obviously do
whatever you want. Really should be a Class Wrapper for a ListBox to expose
a TopIndex property like VB ListBoxes.

' ***CODE START
'Place this code in the General Declarations of your Form
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long

Private Declare Function GetFocus Lib "user32" () As Long

' Windows Message Constant
Private Const WM_VSCROLL = &H115
' Scroll Bar Commands
Private Const SB_THUMBPOSITION = 4
' Code end for General Declarations
' Code for Control's Click Event
Private Sub Customer_Click()

Dim hWndSB As Long
Dim lngRet As Long
Dim lngIndex As Long
Dim LngThumb As Long

' You will get lngIndex value from the user or whatever.
' For now I'm just setting it to arbitrary Number
lngIndex = 45

' SetFocus to our listBox so that we can
' get its hWnd
Me.List2.SetFocus
hWndSB = GetFocus

' Set the window's ScrollBar position
LngThumb = MakeDWord(SB_THUMBPOSITION, CInt(LngIndex))
lngRet = SendMessage(hWndSB, WM_VSCROLL, LngThumb, 0&)

End Sub

' Here's the MakeDWord function from the MS KB
Function MakeDWord(loword As Integer, hiword As Integer) As Long MakeDWord =
(hiword * &H10000) Or (loword And &HFFFF&) End Function '***END CODE
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.

"Pachydermitis" <pr*******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Thanks Stephen,
I actually downloaded that and tried your methodology (slightly
modified of course) on my list box a couple days ago - to no avail.
Your solution is pretty slick. Thanks for making that available to
everyone.
Were you able to get a listbox to scroll horizontally?

Dec 20 '05 #6
Once again thanks for the suggestion(s).
I have been scrolling the box vertically for quite some time using very
similar code. My problem arose when I needed to scroll it
horizontally. I have tried every permutation of the above code that I
can think of in order to scroll Horizontally, but it won't move. For
interests sake I do have the this code in a class.
Thanks again.

Dec 21 '05 #7
If you want to ZIP and email me your MDB containing your working Vertical
and test Horizontal code I will have a look at it for you.
My*********@MyLastName.com

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Pachydermitis" <pr*******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Once again thanks for the suggestion(s).
I have been scrolling the box vertically for quite some time using very
similar code. My problem arose when I needed to scroll it
horizontally. I have tried every permutation of the above code that I
can think of in order to scroll Horizontally, but it won't move. For
interests sake I do have the this code in a class.
Thanks again.

Dec 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pal Csepregi | last post by:
Hi can i remove somehow the horizontal scrollbar? just the horizontal! Thx PallR
5
by: Jsp | last post by:
I created a vertically scrolling div. On initial rendering, Firefox shows a horizontal scrollbar in this div, over the complete width. Resizing the width of the window/viewport makes the horizontal...
4
by: anna | last post by:
How to tell if a horizontal scrollbar is present? I only want to use scrollTo if horizontal scrollbar is present. window.scrollbars.visibility doesn't specify which scrollbar is present, so it...
1
by: Marco Liedekerken | last post by:
Hi, I want a Horizontal scrollbar to appear in my Panel control when I add new controls to it (when the width is getting too big). The Vertical scrollbar is easy (adding overflow: auto to the...
1
by: dhnriverside | last post by:
Hi guys I'm using a div to create a list with ajax stuff. At the moment, the div shows a scrollbar if the content is larger than the div. The problem is that if it isnt, the scrollbar...
4
by: Sakharam Phapale | last post by:
Hi All, I have installed VS .NET 2002 on my machine. I have checked both Vertical scrollbar and Horizontal Scrollbar options, in Tools -> Options-> Text Editor-> General-> Vertical Scrollbar...
2
by: musicmouse | last post by:
Happy new year to you all, I have a problem with the css settings for the horizontal scrollbar of a textarea. When I look at my textarea's in Internet Explorer (I use 5.5) I see only a...
14
by: Michael Weis | last post by:
Hello all, as a non-professional in these things, I searched for this topic but found no satisfying answer: I have to create a site with 3 frames. (Please no diskussion about the sense of...
1
by: malpani.abhijit | last post by:
Hi, I am having a ListView component in my WinForm, when i add some images into it, it gives me a vertical scroll bar. What i want is, the horizontal scrollbar instead of vertical. Is there any...
3
by: j0rd4n | last post by:
I have a user control that needs to allow vertical scrolling but not horizontal scrolling. In the user control's resize event, I need to adjust the size of all the children controls. For this to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.