?
Solved

Horizontal Scroll for listbox

Posted on 1998-09-30
10
Medium Priority
?
387 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
[X]
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
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 200 total points
ID: 1437435
Declare Function GetFocus Lib "user32" Alias "GetFocus" () As Long

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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

752 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