vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#

https://www.vbarchiv.net
Rubrik: Maus & Tastatur · Maus   |   VB-Versionen: VB4, VB5, VB609.01.01
Hotspot-Aktionen

Der nachfolgende Tipp zeigt, wie man Hotspot-Aktionen festlegen kann. Hotspots sind Bereiche, bei denen beim "Darüberfahren" und/oder Klicken mit de...

Autor:   Heinz PrelleBewertung:  Views:  16.231 
www.visual-basic5.deSystem:  Win9x, WinNT, Win2k, WinXP, Win7, Win8, Win10, Win11 Beispielprojekt auf CD 

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



Anzeige

Kauftipp Unser Dauerbrenner!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.
 
 
Copyright ©2000-2024 vb@rchiv Dieter OtterAlle Rechte vorbehalten.


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.