AaronYang
New Member
- Joined
- Nov 1, 2006
- Messages
- 43
Hi,All,
I have a form with height 50 centimeters, and there is a listbox in the left of the form, it is used for pick value. The problem is: when scroll the form, the listbox will disappear with the form page together, how can I keep the listbox always show in the screen?
I try to use below code to capture the scrollbal postion then re-set the listbox TOP properties, but it always show as Zero. Can anybody help me on that? Thanks!
I have a form with height 50 centimeters, and there is a listbox in the left of the form, it is used for pick value. The problem is: when scroll the form, the listbox will disappear with the form page together, how can I keep the listbox always show in the screen?
I try to use below code to capture the scrollbal postion then re-set the listbox TOP properties, but it always show as Zero. Can anybody help me on that? Thanks!
Code:
Option Compare Database
Option Explicit
Public Const SB_HORZ As Long = 0
Public Const SB_VERT As Long = 1
Public Const SB_CTL As Long = 2
Public Type SCROLLINFO
cbSize As Long
fMask As Long
nMin As Long
nMax As Long
nPage As Long
nPos As Long
nTrackPos As Long
End Type
Public Const SIF_RANGE As Long = &H1
Public Const SIF_PAGE As Long = &H2
Public Const SIF_POS As Long = &H4
Public Const SIF_TRACKPOS As Long = &H10
Public Const SIF_DISABLENOSCROLL As Long = &H8
Public Const SIF_ALL As Long = (SIF_RANGE Or SIF_PAGE Or SIF_POS Or SIF_TRACKPOS)
Public Declare Function GetScrollInfo Lib "user32" (ByVal hWnd As Long, ByVal n As Long, lpScrollInfo As SCROLLINFO) As Long
Private Sub Command16_Click()
Dim AA
Dim SI As SCROLLINFO
With SI
.cbSize = Len(SI)
.fMask = SIF_ALL
End With
AA = GetScrollInfo(Me.hWnd, SB_VERT, SI)
MsgBox AA
MsgBox SI.nPos & " ==" & SI.nTrackPos
End Sub