Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / December 2005

Tip: Looking for answers? Try searching our database.

Horizontal Scrollbar

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pachydermitis - 20 Dec 2005 16:06 GMT
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
Steve - 20 Dec 2005 16:47 GMT
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.
Pachydermitis - 20 Dec 2005 18:49 GMT
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.
Stephen Lebans - 20 Dec 2005 19:47 GMT
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.

Signature

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

> Hi all you Experts,
> I need to scroll a listbox horizontally.
[quoted text clipped - 20 lines]
>    MakeDWord = (hiword * &H10000) Or (loword And &HFFFF&)
> End Function
Pachydermitis - 20 Dec 2005 20:13 GMT
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?
Stephen Lebans - 20 Dec 2005 22:02 GMT
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

Signature

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

> 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?
Pachydermitis - 21 Dec 2005 03:41 GMT
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.
Stephen Lebans - 21 Dec 2005 04:41 GMT
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.
MyFIrstName@MyLastName.com

Signature

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

> Once again thanks for the suggestion(s).
> I have been scrolling the box vertically for quite some time using very
[quoted text clipped - 3 lines]
> interests sake I do have the this code in a class.
> Thanks again.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.