List box defilement de gauche a droite

Résolu
petiflamand Messages postés 675 Date d'inscription samedi 31 mai 2003 Statut Membre Dernière intervention 26 mai 2013 - 27 août 2005 à 08:22
jpleroisse Messages postés 1788 Date d'inscription mardi 7 novembre 2000 Statut Membre Dernière intervention 11 mars 2006 - 27 août 2005 à 12:42
Salut je voudrais faire un defilement comme de haut en bas mais de gauche a droite
Merci

1 réponse

jpleroisse Messages postés 1788 Date d'inscription mardi 7 novembre 2000 Statut Membre Dernière intervention 11 mars 2006 27
27 août 2005 à 12:42
Bonjour,

Option Explicit
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, _
ByVal nCount As Long, lpRect As RECT, _
ByVal wFormat As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
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 Const LB_SETHORIZONTALEXTENT = &H194
Private Const DT_CALCRECT = &H400
Private Const SM_CXVSCROLL = 2


Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type


Public Sub ApplyScrollBar(ByVal hdc As Long, MaListe As ListBox)


Dim compteur As Long, Nlargeur As Long, LargText As Long, sysScrollWidth As Long
Dim rcText As RECT

sysScrollWidth = GetSystemMetrics(SM_CXVSCROLL)
For compteur = 0 To MaListe.ListCount - 1
DrawText hdc, MaListe.List(compteur), -1&, rcText, DT_CALCRECT
LargText = rcText.Right + sysScrollWidth
If LargText >= Nlargeur Then
Nlargeur = LargText
End If
Next compteur
SendMessage MaListe.hwnd, LB_SETHORIZONTALEXTENT, Nlargeur, ByVal 0&
End Sub

Private Sub Form_Load()
List1.AddItem "SrollBar dans ListBox"
List1.AddItem "Lorsque le texte sera plus large que la ListBox, la barre de défilement apparaîtra"
ApplyScrollBar Me.hdc, List1
End Sub

jpleroisse
3
Rejoignez-nous