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
Solved

Listbox Horizontal Scroll

Posted on 1998-11-04
3
707 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 80 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

791 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