Results 1 to 3 of 3

Thread: Listbox and scrollbar

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    21

    Post

    Hi,

    As you know, a scrollbar automaticaly appears on a listbox.

    I'm just trying to detect in my app. when this scrollbar appears, thats all...

    Thanks.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Try checking for the WS_VSCROLL Flag in the Listbox's Window Style, ie.
    Code:
    'Add a Timer, a Listbox and 2 Command Buttons to a Form..
    '
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Const GWL_STYLE = (-16)
    Private Const WS_VSCROLL = &H200000
    
    Private Sub Form_Load()
        Timer1.Interval = 100
    End Sub
    
    Private Sub Timer1_Timer()
        'Check if the Listbox has the WS_VSCROLL Style
        Caption = IIf(GetWindowLong(List1.hwnd, GWL_STYLE) And WS_VSCROLL, "Scrollbar Visible", "Scrollbar Hidden")
    End Sub
    
    Private Sub Command1_Click()
        'Add an Item to the List
        List1.AddItem "Item " & List1.ListCount + 1
    End Sub
    
    Private Sub Command2_Click()
        'Remove an Item from the List
        List1.RemoveItem List1.ListCount - 1
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Certified AllExperts Expert

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    21

    Post

    Thanks a lot.

    Claude.

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