Solved

Horizontal Scroll for listbox

Posted on 1998-09-30
10
379 Views
Last Modified: 2012-06-22
Anyone have the code for horizontal scroll in listbox?  I think there is an API to determine this.


Specialist
0
Comment
Question by:SPECIALIST
10 Comments
 
LVL 7

Expert Comment

by:tward
ID: 1437433
Public Const LB_SETHORIZONTALEXTENT = &H194

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


Public Sub AddHScrollToListBox(ByVal FormWithControl As Form, ByVal ListBox As Control, ByVal FullString As String)

  Dim ListHwnd As Long
  Static GreatestWidth As Long

  ' Get Focus of the ListBox to Make A Horizontal Scroll Bar For '
  ListBox.SetFocus
  ListHwnd = GetFocus()

  If FormWithControl.TextWidth(FullString) > GreatestWidth Then

    ' Add/Change Size of Horizontal Scroll Bar '
    Call SendMessage(ListHwnd, LB_SETHORIZONTALEXTENT, FormWithControl.TextWidth(FullString), NUL)
    GreatestWidth = FormWithControl.TextWidth(FullString)
    DoEvents

  End If

End Sub


0
 
LVL 3

Author Comment

by:SPECIALIST
ID: 1437434
Thanks I just have one error Getfocus says "sub or function not defined"

Just need that sub!

Specialist
0
 
LVL 1

Accepted Solution

by:
CarlosJac earned 50 total points
ID: 1437435
Declare Function GetFocus Lib "user32" Alias "GetFocus" () As Long

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1437436
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA"
     (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long,
     ByRef lParam As Long) As Long

const LB_SETHORIZONTALEXTENT = 404

dim s as long

s = SendMessage(ListBox1.hWnd, LB_SETHORIZONTALEXTENT, 500, 0)

//Can you do like this in VB???->>> ListBox1.hWnd

Regards,
Viktor Ivanov
0
 
LVL 7

Expert Comment

by:tward
ID: 1437437
Sorry about that, forgot the one declaration.  I would have posted it but someone beat me to it...
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 3

Author Comment

by:SPECIALIST
ID: 1437438
tward,

sorry I know you answered first, but I asked for clarification, after a few hours I had to re-post due to time limitations.

Sorry!
Specialist

0
 
LVL 3

Author Comment

by:SPECIALIST
ID: 1437439
One other thing, what is the 3rd argument?  fullstring as string?

should be ok after that!

Thanks
0
 
LVL 7

Expert Comment

by:tward
ID: 1437440
The function I did gets called after anything is added to the Listbox so I pass the string that was added and try to calculate the size of the Scroll bar based on the Text that was added.
0
 
LVL 3

Author Comment

by:SPECIALIST
ID: 1437441
Thanks!
0
 
LVL 1

Expert Comment

by:Vingamel
ID: 2509106
Can somebody provide an example of calling this API function?  Thanks.
--Vingamel
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now