?
Solved

Listbox Horizontal Scroll

Posted on 1998-11-04
3
Medium Priority
?
726 Views
Last Modified: 2013-12-26
How do you add a horizontal scroll bar to a list box ?
I have only one column but the text lenght for each row is actually longer the listbox width I defined. I could not found a horizontal scroll bar function.

Vertical Scroll bar appears when the row gets bigger than the lenght of the listbox, but I cannot do that for horizontal ??

Thanks

Edith
0
Comment
Question by:Edithf
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 320 total points
ID: 1488121
Const LB_SETHORIZONTALEXTENT = &H194
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
     (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
     lParam As Any) As Long

Dim x As Long
x = SendMessage(list1.hWnd, LB_SETHORIZONTALEXTENT, list1.Width * 2, _
     ByVal 0&)

Note: the `list1.Width*2' parameter specifies the scrollable width of the
listbox in pixels. You may need to adjust the form's ScaleMode or
otherwise experiment to find the best value.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1488122
Here is also a function for automatic adjustment. Call this function whenever the listbox is changed.

Declare Function SendMessage Lib "user32" Alias
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long,
ByVal wParam As Long, lParam As Long) As Long

Const WM_USER = &H400
Const LB_SETHORIZONTALEXTENT = WM_USER + 21

Sub CheckListBox
    Dim i%, res&
    Dim Scrollwidth&
   
    For i% = 0 To Form1.List1.ListCount
       If Form1.TextWidth(Form1.List1.List(i%)) > Scrollwidth& Then _
        Scrollwidth& = Form1.TextWidth(Form1.List1.List(i%))
    Next i%

    res& = SendMessage(Form1.List1.hWnd, LB_SETHORIZONTALEXTENT, _
        Scrollwidth&, 0&)
End Sub

0
 
LVL 1

Author Comment

by:Edithf
ID: 1488123
Thanks it works well now ....... I always have problem looking up for the function in the Library. Does the library function include in the C++ help ?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

807 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