VB4, list boxes, and horizontal scroll bars CHALLENGE! 
Author Message
 VB4, list boxes, and horizontal scroll bars CHALLENGE!

Microsoft has an app note out for VB 3 and below that explains how to make a
horizontal scroll bar visible for a list box, using the SendMessage command and
LB_SETHORIZONTALEXTENT.

When I try to port this code to VB 4, the scroll bar never shows up.

I have tried:
        1. The 32 bit declaration from the API viewer.
        2. Checking the listbox's Style flags (They include WS_HSCROLL)
        3. The new value for LB_SETHORIZONTALEXTENT

THE CHALLENGE:

To make the horizontal scroll bar on a standard VB list box visible using 32 bit VB
4.0 (Pro, if it matters).

Any takers?

Desi



Sat, 05 Sep 1998 03:00:00 GMT  
 VB4, list boxes, and horizontal scroll bars CHALLENGE!
On Tue, 19 Mar 1996 16:38:49 -0500, Desi Richards

Quote:

>Microsoft has an app note out for VB 3 and below that explains how to make a
>horizontal scroll bar visible for a list box, using the SendMessage command and
>LB_SETHORIZONTALEXTENT.

>  <snip>

>To make the horizontal scroll bar on a standard VB list box visible using 32 bit VB
>4.0 (Pro, if it matters).

>Any takers?

>Desi

Gee, must be a trick question.  I copied the example directly into VB
4.0 (32 bit) under Windows 95, changed the API calls to the
appropriate 32-bit counterparts, and wahlah (how IS that spelled?), I
have a scroll bar on my list box.  Here is the code:

Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Long) As Long

Declare Function GetFocus Lib "user32" () As Long

Sub Command1_Click()
   Const LB_SETHORIZONTALEXTENT = &H400 + 21
   Const NUL = 0&
   ' wParam is in PIXEL(3).
   ScaleMode = 3

   ' Get the handle.
   List1.SetFocus
   ListHwnd% = GetFocus()

   ' This string will show up initially.
   ListString1$ = "Derek is a great "

   ' You can scroll to see this portion.
   ListString2$ = "little boy "

   ' You cannot scroll to see this string.
   ListString3$ = "but can be a problem sometimes"

   ExtraPixels% = TextWidth(ListString2$)
   BoxWidth% = TextWidth(ListString1$)

   ' Resize the text box.
   List1.Move List1.Left, List1.Top, BoxWidth%

   ' Add the scroll bar.
   X& = SendMessage(ListHwnd%, LB_SETHORIZONTALEXTENT, _
      BoxWidth% + ExtraPixels%, NUL)

   ' Add the example string to the list box.
   List1.AddItem ListString1$ + ListString2$ + ListString3$

End Sub

Let me know if this doesn't work...

Jeff



Wed, 09 Sep 1998 03:00:00 GMT  
 VB4, list boxes, and horizontal scroll bars CHALLENGE!


Quote:
> Gee, must be a trick question.  I copied the example directly into VB
> 4.0 (32 bit) under Windows 95, changed the API calls to the
> appropriate 32-bit counterparts, and wahlah (how IS that spelled?), I

I may be off-topic, but it's 'voila'...  Merci...

--
Cheers,

Ben

------------------====### legal notice ###====-----------------------
Microsoft Network is prohibited from redistributing this work in any
form,in whole or in part.  License to distribute this post is available to
Microsoft for $499.  Posting without permission constitutes an agreement to
these terms.



Thu, 17 Sep 1998 03:00:00 GMT  
 VB4, list boxes, and horizontal scroll bars CHALLENGE!

Quote:
> > appropriate 32-bit counterparts, and wahlah (how IS that spelled?), I
> I may be off-topic, but it's 'voila'...  Merci...

don't forget the accent on the 'a': voil&agrave;'

--
--------------------------------------------------------------------
Patrick Dostert                 |       famous last words:

--------------------------------------------------------------------
my opinions are strictly my own but may reflect those of my employer
--------------------------------------------------------------------



Tue, 29 Sep 1998 03:00:00 GMT  
 VB4, list boxes, and horizontal scroll bars CHALLENGE!


He Said:

Quote:
> > > appropriate 32-bit counterparts, and wahlah (how IS that spelled?), I

I Said:

Quote:
> > I may be off-topic, but it's 'voila'...  Merci...

You Said:

Quote:
> don't forget the accent on the 'a': voil&agrave;'

I Say:

:)    (However you say that <Grin>)

--
Cheers,

Ben

------------------====### legal notice ###====-----------------------
Microsoft Network is prohibited from redistributing this work in any
form,in whole or in part.  License to distribute this post is available to
Microsoft for $499.  Posting without permission constitutes an agreement to
these terms.



Tue, 29 Sep 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. VB4, list boxes, and horizontal scroll bars CHALLENGE!

2. Horizontal Scroll Bar for a list box VB4

3. Need a List Box with a Horizontal Scroll Bar

4. Adding horizontal scroll bars to a dir list box

5. Horizontal Scroll bar in List Box

6. adding horizontal scroll bar to list box

7. adding horizontal scroll bar to list box

8. Adding a horizontal scroll bar to File and Dir List Box

9. List Box: Adding a Horizontal and Vertical Scroll Bar

10. How do you add a horizontal scroll bar to a file list box control

11. Add Horizontal Scroll bar to List Box

12. List with horizontal scroll bar?

 

 
Powered by phpBB® Forum Software