|
-
January 10th, 2000, 10:27 AM
#1
No scrollbar in a listbox
Hi,
Is it possible to have a listbox without a vertical scrollbar, when the list becomes longer then the lenght of the listbox?
Thanx, Maarten
-
January 10th, 2000, 11:31 AM
#2
Re: No scrollbar in a listbox
I'm a bit confused as to why you'd want this, but here's how to do it any way :
Paste the following code into a new form (FORM1) containing a ListBox (LIST1) :
option Explicit
'
' Win API Declares
'
private Declare Function ShowScrollBar Lib "user32" (byval hwnd as Long, _
byval wBar as Long, byval bShow as Long) as Long
private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (byval hwnd as Long, byval nIndex as Long) as Long
private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (byval hwnd as Long, byval nIndex as Long, byval _
dwNewLong as Long) as Long
'
'
private Const SB_VERT = 1
private Const WS_VSCROLL = &H200000
private Const GWL_STYLE = (-16)
'
'
private Sub Form_Load()
'
Dim l as Long
Dim lStyle as Long
'
' Add some items to the scrollbar
'
for l = 1 to 255
List1.AddItem "Item " & l
next
'
' Hide any visible scrollbar
'
ShowScrollBar List1.hwnd, SB_VERT, 0
'
' get Window Style Bit
'
lStyle = GetWindowLong(List1.hwnd, GWL_STYLE)
'
' Remove Scrollbar from style
'
lStyle = lStyle Xor WS_VSCROLL
'
' set the new window style of the listbox
'
lStyle = SetWindowLong(List1.hwnd, GWL_STYLE, lStyle)
'
End Sub
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
-
January 11th, 2000, 06:54 AM
#3
Re: No scrollbar in a listbox
It works just like I want to.
Great work.
Thanx very much!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|