Der nachfolgende Tipp zeigt, wie man Hotspot-Aktionen festlegen kann. Hotspots sind Bereiche, bei denen beim "Darüberfahren" und/oder Klicken mit der Maus eine bestimmte Aktion ausgelöst wird. Im nachfolgenden Beispiel wird ein Sound abgespielt, wenn Sie die Maus über einen sogenannten Hotspot-Bereich (Picture-Objekt) bewegen. Klicken Sie auf das Picture-Objekt, so ändert sich das Bild. Um den Tipp besser nachvollziehen zu können, empfehlen wir Ihnen sich das Beispiel "downzuloaden". ' IN FORM: ' Beispiel : HOTSPOT... ' Begin Code Option Explicit Const conNORMALSTATUS = 1 Const conAKTIVERSTATUS = 2 Const conKLICKSTATUS = 3 Dim intStaSpot As Integer Dim intAktSpot As Integer Private Sub Form_MouseMove(Button As Integer, _ Shift As Integer, X As Single, Y As Single) If intStaSpot = conAKTIVERSTATUS Then HotSpot(intAktSpot).Picture = Picture1.Picture intStaSpot = conNORMALSTATUS intAktSpot = -1 End If End Sub Private Sub HotSpot_MouseDown(Index As Integer, _ Button As Integer, Shift As Integer, X As Single, _ Y As Single) Dim intTmp As Integer If intStaSpot <> conKLICKSTATUS Then HotSpot(Index).Picture = Picture3.Picture intTmp = sndPlaySound(ByVal (App.Path + _ "\ding.wav"), SYNC) intStaSpot = conKLICKSTATUS intAktSpot = Index End If End Sub Private Sub HotSpot_MouseMove(Index As Integer, _ Button As Integer, Shift As Integer, X As Single, _ Y As Single) Dim intTmp As Integer If intStaSpot = conNORMALSTATUS Then HotSpot(Index).Picture = Picture2.Picture intTmp = sndPlaySound(ByVal (App.Path + _ "\boing.wav"), SYNC) intStaSpot = conAKTIVERSTATUS intAktSpot = Index End If End Sub Private Sub HotSpot_MouseUp(Index As Integer, _ Button As Integer, Shift As Integer, X As Single, _ Y As Single) If intStaSpot <> conAKTIVERSTATUS Then HotSpot(Index).Picture = Picture2.Picture intStaSpot = conAKTIVERSTATUS intAktSpot = Index End If End Sub Private Sub Form_Initialize() Dim intZaehler As Integer intStaSpot = 1 intAktSpot = -1 For intZaehler = 0 To Me.Controls.Count - 1 If Me.Controls(intZaehler).Name = "HotSpot" Then Me.Controls(intZaehler).Picture = Picture1.Picture End If Next End Sub ' End Code Form ' In Modul: ' Begin Code Option Explicit Declare Function sndPlaySound Lib "winmm" _ Alias "sndPlaySoundA" ( _ ByVal lpszSoundName As String, _ ByVal uFlags As Long) As Long Public Const SYNC = 1 ' End Cod Dieser Tipp wurde bereits 16.245 mal aufgerufen. Voriger Tipp | Zufälliger Tipp | Nächster Tipp
Anzeige
Diesen und auch alle anderen Tipps & Tricks finden Sie auch auf unserer aktuellen vb@rchiv Vol.6 (einschl. Beispielprojekt!) Ein absolutes Muss - Geballtes Wissen aus mehr als 8 Jahren vb@rchiv! - nahezu alle Tipps & Tricks und Workshops mit Beispielprojekten - Symbol-Galerie mit mehr als 3.200 Icons im modernen Look Weitere Infos - 4 Entwickler-Vollversionen (u.a. sevFTP für .NET), Online-Update-Funktion u.v.m. |
vb@rchiv CD Vol.6 Geballtes Wissen aus mehr als 8 Jahren vb@rchiv! Online-Update-Funktion Entwickler-Vollversionen u.v.m. Tipp des Monats Mai 2024 Hermann Röttger Wochentage eines Datumsbereichs ermitteln Wochentage eines Datumsbereichs ermitteln, optional mit Feiertagsberechnung sevZIP40 Pro DLL Zippen und Unzippen wie die Profis! Mit nur wenigen Zeilen Code statten Sie Ihre Anwendungen ab sofort mit schnellen Zip- und Unzip-Funktionen aus. Hierbei lassen sich entweder einzelnen Dateien oder auch gesamte Ordner zippen bzw. entpacken. |
||||||||||||||||
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein. |