![]() |
Tipp 0521
|
Laufschrift in einer ComboBox
|
 |
|
Autor/Einsender: Datum: |
|
Elmar Valeske 07.11.2006 |
|
Entwicklungsumgebung: |
|
VB 6 |
|
|
Ganz ohne API-Funktionen lässt sich eine Laufschrift in einer ComboBox realisieren, und zwar indem in eine nicht sichtbare PictureBox
(Visible = False), die als Puffer dient, mit der Print-Methode ein Wunschtext hineingeschrieben wird. Dieser Text wird
mit der PaintPicture-Methode ausgelesen, und in einer zweiten sichtbaren PictureBox (Visible = True)
ausgegeben.
|
Die sichtbare PictureBox dient gleichzeitig als Laufschrift-Ausgabefeld, und wird mit der ZOrder-Methode über die ComboBox
"geblendet". Mittels zweier Timer entsteht so eine ComboBox mit einer Laufschrift.
|
|
|
Private Const Fontgroesse = 9
Private Const BackGroundColor = vbGreen
Private Const ww0 = " The Eagle has landed. These words ..."
Private Const ww1 = " Vitali Klitschko vs Danny Williams ..."
Private Const ww2 = " VB-fun.de "
Dim TXT(3) As String, xTick As Integer
Private Sub Form_Load()
TXT(0) = ww0: TXT(1) = ww1: TXT(2) = ww2
With Combo1
.AddItem TXT(0)
.AddItem TXT(1)
.AddItem TXT(2)
.FontSize = Fontgroesse
End With
With Picture1
.FontSize = Fontgroesse
.Visible = False
.AutoRedraw = -1
.BorderStyle = 0
.BackColor = BackGroundColor
End With
With Picture2
.BorderStyle = 0
.BackColor = BackGroundColor
.Move Combo1.Left + 30, Combo1.Top + 30, _
Combo1.Width - 15 * 20, Combo1.Height - 60
End With
Combo1.ListIndex = 0
End Sub
Private Sub Combo1_Click()
Dim strTxt As String
Timer1.Enabled = 0
Timer2.Enabled = 0
strTxt = Combo1.List(Combo1.ListIndex)
Picture2.ZOrder (0)
With Picture1
.Cls
.CurrentY = 0
.Width = TextWidth(strTxt) + 30
End With
Picture1.Print strTxt
Timer2_Timer
End Sub
Private Sub Combo1_DropDown()
Timer1.Enabled = 0
Timer2.Enabled = 0
End Sub
Private Sub Timer1_Timer()
Ticker
End Sub
Sub Ticker()
Timer1.Interval = 0
Timer2.Interval = 0
Picture2.PaintPicture Picture1.Image, -xTick, 30
xTick = xTick + 30
If xTick > TextWidth(Combo1.List(Combo1.ListIndex)) Then
Timer1.Interval = 0
Timer2.Interval = 1000
Exit Sub
End If
Timer1.Interval = 50
End Sub
Private Sub Timer2_Timer()
xTick = (-1 * Picture2.Width + 15 * 20)
Picture2.Cls
Timer1.Enabled = -1
Timer2.Enabled = -1
Ticker
End Sub
|
|
|
|
|
Windows-Version |
95 |
 |
|
98 |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
VB-Version |
VBA 5 |
 |
|
VBA 6 |
 |
|
VB 4/16 |
 |
|
VB 4/32 |
 |
|
VB 5 |
 |
|
VB 6 |
 |
|
|
|
Download (2,9
kB)
|
Downloads bisher: [ 389 ]
|
|
|