Scrolling+a+list+box

//by Richard Russell, March 2007//

You can scroll the contents of a list box, under the control of your own program, by sending it a **WM_VSCROLL** message. The simple program below illustrates the use of that technique:

code format="bb4w" INSTALL @lib$+"WINLIB5" WS_VSCROLL = &200000 WS_BORDER = &800000 LB_ADDSTRING = 384 WM_VSCROLL = 277 SB_BOTTOM = 7 hlist%=FN_listbox("", 20, 20, 200, 200, 1, WS_VSCROLL + WS_BORDER) REPEAT WAIT 50 item% += 1 SYS "SendMessage", hlist%, LB_ADDSTRING, 0, "Line "+STR$item% SYS "SendMessage", hlist%, WM_VSCROLL, SB_BOTTOM, 0 UNTIL FALSE code Here the **SB_BOTTOM** scroll command is sent, which causes the list box to scroll so the last item is in view. The full set of commands is as follows:

code format="bb4w" SB_LINEUP = 0  : REM Scrolls one line up      SB_LINEDOWN = 1 : REM scrolls one line down SB_PAGEUP = 2  : REM Scrolls one page up      SB_PAGEDOWN = 3 : REM Scrolls one page down SB_TOP = 6     : REM Scrolls to the top SB_BOTTOM = 7  : REM scrolls to the bottom code The code shown is appropriate for scrolling a list box on your main window. You can similarly scroll a listbox within a dialogue box by using **SendDlgItemMessage** as below:

code format="bb4w" SYS "SendDlgItemMessage", !dlg%, idlist%, WM_VSCROLL, SB_BOTTOM, 0 code