Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling Listbox Scrolling SendMessage WM_VSCROLL

Status
Not open for further replies.

papadilbert

Programmer
Sep 24, 2004
23
0
0
US
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
 
I tried commenting out the following lines from the example above to see if I would get a different result. I get the same result.

To me, this would indicate that SendMessage() is doing nothing. I'm continuing to look for a solution.

' hWndSB = GetFocus
' LngThumb = MakeDWord(SB_THUMBPOSITION, _
' CInt(aListbox.ListIndex))
' IngRet = SendMessage(hWndSB, WM_VSCROLL, LngThumb, 0&)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top