papadilbert
Programmer
First, let me start by thanking everyone for your support and patience with my previous posts!
After setting aListbox.ListIndex I'm attempting to scroll the listbox so the ListIndex entry is displayed at the top of the listbox. Instead, it seems to always be displayed at the bottom.
What controls the direction of the scroll anyway (up/down) ?
Where have I gone wrong?
(reference: )
----------
The following is code included in the general declarations of the form:
----------
Private Declare Function SendMessage Lib "user32" Alias _
SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, IParam As Any) As Long
Private Declare Function GetFocus Lib "user32" () As Long
' Windows Message Constant
Private Const WM_VSCROLL = &H115
'Scroll Bar Commands
Private Const SB_THUMBPOSITION = 4
----------
This snippet of code is executed by a button click.
The variable i is the row of the listbox that I want to display at the top of the listbox.
----------
aListbox.SetFocus
aListtbox.ListIndex = i - 1
hWndSB = GetFocus
LngThumb = MakeDWord(SB_THUMBPOSITION, _
CInt(aListbox.ListIndex))
IngRet = SendMessage(hWndSB, WM_VSCROLL, LngThumb, 0&)
---------
Function to format DoubleWord
---------
Function MakeDWord(loword As Integer, hiword As Integer) As Long
MakeDWord = (hiword * &H10000) Or (loword And &HFFFF&)
End Function
After setting aListbox.ListIndex I'm attempting to scroll the listbox so the ListIndex entry is displayed at the top of the listbox. Instead, it seems to always be displayed at the bottom.
What controls the direction of the scroll anyway (up/down) ?
Where have I gone wrong?
(reference: )
----------
The following is code included in the general declarations of the form:
----------
Private Declare Function SendMessage Lib "user32" Alias _
SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, IParam As Any) As Long
Private Declare Function GetFocus Lib "user32" () As Long
' Windows Message Constant
Private Const WM_VSCROLL = &H115
'Scroll Bar Commands
Private Const SB_THUMBPOSITION = 4
----------
This snippet of code is executed by a button click.
The variable i is the row of the listbox that I want to display at the top of the listbox.
----------
aListbox.SetFocus
aListtbox.ListIndex = i - 1
hWndSB = GetFocus
LngThumb = MakeDWord(SB_THUMBPOSITION, _
CInt(aListbox.ListIndex))
IngRet = SendMessage(hWndSB, WM_VSCROLL, LngThumb, 0&)
---------
Function to format DoubleWord
---------
Function MakeDWord(loword As Integer, hiword As Integer) As Long
MakeDWord = (hiword * &H10000) Or (loword And &HFFFF&)
End Function