|
-
Aug 3rd, 2000, 02:35 PM
#1
Thread Starter
Junior Member
Tricky one for those that think they are GUI experts. How do you get a listbox to scroll horizontally.
-
Aug 3rd, 2000, 02:53 PM
#2
Monday Morning Lunatic
Well, it needs to be done when the control is initialised, by using the WS_HSCROLL window style. Unfortunately, it can't be changed after it's been created. If a new list box was created, then it could be used that way. I'll try knocking up a more useful list box and get back to you.
[Edited by parksie on 08-03-2000 at 03:59 PM]
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 3rd, 2000, 03:11 PM
#3
_______
<?>
Code:
Option Explicit
Const LB_SETHORIZONTALEXTENT = &H194 'Used in the SendMessage 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
Private Sub Form_Load()
dim x
X = SendMessage(List1.hwnd, LB_SETHORIZONTALEXTENT, 350, 0) 'Win API function to set the scrollbar
List1.AddItem ":DFJKD:JFLSDJFDSJFL:DSLF:JDSFJLSDJFLSDJFLSJLFDSFJLSDJFLDSJLKF"
End Sub
[Edited by HeSaidJoe on 08-03-2000 at 04:15 PM]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 3rd, 2000, 03:25 PM
#4
Monday Morning Lunatic
Doesn't work. The problem is with the window style, I think.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 3rd, 2000, 03:28 PM
#5
Thread Starter
Junior Member
-
Aug 3rd, 2000, 03:28 PM
#6
_______
<?>
works fine on my pc...what are you running?
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 3rd, 2000, 03:30 PM
#7
Thread Starter
Junior Member
I just found a MS KB article on it, using your same method.
Option Explicit
Private Declare Function SendMessageByNum Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal _
wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const LB_SETHORIZONTALEXTENT = &H194
Private Sub Command1_Click()
Dim s As String
Static x As Long
s = InputBox("Please enter any text", "List scroll", _
"this is a simple scrollbar sample for demonstration purposes")
List1.AddItem s
If x < TextWidth(s & " ") Then
x = TextWidth(s & " ")
If ScaleMode = vbTwips Then _
x = x / Screen.TwipsPerPixelX ' if twips change to pixels
SendMessageByNum List1.hwnd, LB_SETHORIZONTALEXTENT, x, 0
End If
End Sub
-
Aug 3rd, 2000, 03:32 PM
#8
It should work:
Code:
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
Const LB_SETHORIZONTALEXTENT = &H194
Private Sub Command1_Click()
Call SendMessage(List1.hwnd, LB_SETHORIZONTALEXTENT, 350, 0)
End Sub
-
Aug 3rd, 2000, 03:34 PM
#9
Monday Morning Lunatic
swine's KB method works...
HeSaidJoe: W98/PIII/VB5 Enterprise
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 3rd, 2000, 03:40 PM
#10
_______
<?>
Parksie:
weird stuff
...Megatron has exactly the same code and he is running VB5 and it works for him, so it should work on yours too...
I'm running 6...
OH..well, long as swine is happy and it works for him.
Later.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 5th, 2000, 07:05 AM
#11
Monday Morning Lunatic
You're right. He needs it, and it works for him. That's all we're concerned about here. Although why it doesn't work on mine needs checking...I'll see what the problem is.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|