Results 1 to 2 of 2

Thread: Horizontal scroll bar in listbox?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Missouri
    Posts
    3

    Question

    Using VB 6 SP3 and the standard list box, how can I add a horizontal scroll bar to the box? I know it is an API call, I've done it before, but for the life of me cannot remember how to do it.

    Can anyone help me out here?

    Thanks,
    David

    VB 6 Enteprise with SP5 Enterprise

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb From MSDN Library

    I just come across this from MSDN Library.

    Code:
       '======== General Declarations for Form1  ==================
       ' For VB4 16-bit, add the keyword Private before each Declare,
       ' and enter the following Declare as one, single line:
       Declare Function SendMessage& Lib "user" (ByVal hWnd%, ByVal wMsg%,
         ByVal wParam%, ByVal lParam&)
       Declare Function GetFocus Lib "User" () as Integer
    
       '======== Form1 =======================
       'NOTE: each command must appear on one, single line.
    
       Sub Command1_Click ()
          Const LB_SETHORIZONTALEXTENT = &H400 + 21
          Const NUL = 0&
          ' wParam is in PIXEL(3).
          ScaleMode = 3
    
          ' Get the handle.
          List1.SetFocus
          ListHwnd% = GetFocus()
    
          ' This string will show up initially.
          ListString1$ = "Derek is a great "
    
          ' You can scroll to see this portion.
          ListString2$ = "little boy "
    
          ' You cannot scroll to see this string.
          ListString3$ = "but can be a problem sometimes"
    
          ExtraPixels% = TextWidth(ListString2$)
          BoxWidth% = TextWidth(ListString1$)
    
          ' Resize the text box.
          List1.Move List1.Left, List1.Top, BoxWidth%
    
          ' Add the scroll bar.
          X& = SendMessage(ListHwnd%, LB_SETHORIZONTALEXTENT,
             BoxWidth% + ExtraPixels%, NUL)
    
          ' Add the example string to the list box.
          List1.AddItem ListString1$ + ListString2$ + ListString3$
       End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width