Listbox with Horizontal Scrollbar


'listbox with horizontal scrollbar
'by Alyce Watson, Jerry Muelver

NoMainWin
WindowWidth=260:WindowHeight=180

'make a long line and put into array for demo
For i = 1 to 10
m$="Line ";i;" of text to put in the listbox."
a$(i)=m$
Next

stylebits #1.a, _WS_HSCROLL,0,0,0
button #1.b, "Get Choice",[choice],UL,120,10,120,24
button #1.quit, "Exit",[quit],UL,120,40,120,24
Listbox #1.a, a$(),[do],10,10,100,100
Open "Scroll List" For Window As #1
#1 "trapclose [quit]"

'set font of known width:
#1.a "font ms_sans_serif 6 12"

'select an item
#1.a "selectindex 5"

'estimate horizontal extent needed by multiplying
'font width+1 by length of text
textLen=7*(len(m$))

'set horizontal extent:
call SendMessage hwnd(#1.a),_LB_SETHORIZONTALEXTENT,textLen,0

'resize listbox to accomodate horizontal scroll bar
#1.a "locate 10 10 100 120"
#1 "refresh"

Wait
[quit]
Close #1:End

[choice]
#1.a "selection? sel$"
notice "Chosen:  ";sel$
wait

Sub SendMessage hWnd,msg,w,p
    CallDLL #user32, "SendMessageA",_
    hWnd As Long, _
    msg As Long, w As Long,_
    p As long, re As Long
    End Sub


Home

Source Code

Utilities

Internet

Games

Graphics

Media Demos

Snippets

DLL's

API Resources

Freeware

LB 4 Companion

Mastering LB 3

LB Workshop

Game Workshop

Links

Index