Results 1 to 3 of 3

Thread: returning a scroll bar to original position

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    20

    returning a scroll bar to original position

    I was able to add a scroll bar to a combobox but the problem being that that scroll bar remebers its position next time it is dropped down hwo would you reset the position of the scroll bar ??

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    What code did you use to add the scroll bar?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    20
    A combination of 3 apis
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lparam As Any) As Long
    Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, ByVal bShow As Long) As Long
    Private Declare Function GetComboBoxInfo Lib "user32.dll" (ByVal hwndCombo As Long, CBInfo As COMBOBOXINFO) As Long

    Private Const SB_BOTH = 3
    Private Const SB_HORZ = 0
    Private Const SB_VERT = 1
    Private Const SB_CTL = 2

    Private Const CB_SETHORIZONTALEXTENT = &H15E
    Private Const CB_GETHORIZONTALEXTENT = &H15D

    Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type

    Private Type COMBOBOXINFO
    lSize As Long
    rcItem As RECT
    rcButton As RECT
    lButton As Long
    lHwndCombo As Long
    lHwndEdit As Long
    lHwndList As Long
    End Type

    Dim lHList As Long

    Private Sub cboTest2_DropDown()

    Dim lDropdownWidth As Long

    lHList = GetComboListHandle(cboTest2)

    ShowScrollBar lHList, SB_HORZ, 1

    SendMessage cboTest2.hwnd, CB_SETHORIZONTALEXTENT, 400, ByVal 0


    End Sub


    Private Function GetComboListHandle(ctl As ComboBox) As Long

    Dim CBI As COMBOBOXINFO

    CBI.lSize = Len(CBI)
    Call GetComboBoxInfo(ctl.hwnd, CBI)
    GetComboListHandle = CBI.lHwndList

    End Function

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