by milevets (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (7 Votes)
Ever wanted to automatically scroll (vertical) ListBox or MSFlexGrid? Below is a quick solution and it's especially handy when you cannot use object.TopRow (due to variable row height, etc).
Happy Coding
API Declarations'Import Win32 API function
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
'Constant
Const WM_VSCROLL = &H115
Const SB_BOTTOM = 7
'Call below where auto scroll is intended
SendMessage MSFG.hwnd, WM_VSCROLL, SB_BOTTOM, 0
'MSFG is my FlexGrid control, can be changed to ListBox