VB-Homepage Tipp 106

Auswerten ob linker oder rechter Mausklick

Da Sie diesen Tipp gewählt haben, geh ich davon aus, das Ihnen nicht bekannt ist, wie man ermitteln kann, ob mit der linken oder der rechten Maustaste geklickt wurde. Damit es einfach nach zu vollziehen ist, hab ich ein kleines VB4-Projekt für Sie erstellt.

mouse_lr.vbp
Form=mouse_lr.frm
ProjWinSize=90,390,320,492
ProjWinShow=2
Name="Projekt1"
HelpContextID="0"
StartMode=0
VersionCompatible32="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0

mouse_lr.frm
VERSION 4.00
Begin VB.Form Form1
Caption = "VB-Homepage Tipp"
ClientHeight = 4470
ClientLeft = 2475
ClientTop = 2310
ClientWidth = 2775
Height = 4875
Left = 2415
LinkTopic = "Form1"
ScaleHeight = 4470
ScaleWidth = 2775
Top = 1965
Width = 2895
Begin VB.Label Label5
Alignment = 2 'Center
Caption = "Auswertung rechte/linke Maustaste"
Height = 255
Left = 0
TabIndex = 4
Top = 4200
Width = 2775
End
Begin VB.Label Label4
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "Rechts"
Height = 255
Left = 1320
TabIndex = 3
Top = 2040
Width = 735
End
Begin VB.Label Label3
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "Links"
Height = 255
Left = 720
TabIndex = 2
Top = 2040
Width = 495
End
Begin VB.Line Line1
X1 = 1320
X2 = 1680
Y1 = 3720
Y2 = 4080
End
Begin VB.Shape Shape3
FillColor = &H00808080&
FillStyle = 0 'Solid
Height = 975
Left = 600
Shape = 4 'Rounded Rectangle
Top = 1680
Width = 735
End
Begin VB.Shape Shape1
FillColor = &H00808080&
FillStyle = 0 'Solid
Height = 975
Left = 1320
Shape = 4 'Rounded Rectangle
Top = 1680
Width = 735
End
Begin VB.Shape Shape2
Height = 2055
Left = 600
Shape = 4 'Rounded Rectangle
Top = 1680
Width = 1455
End
Begin VB.Label Label1
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H000000C0&
BorderStyle = 1 'Fixed Single
Caption = "Klick mich"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 375
Left = 750
TabIndex = 0
Top = 600
Width = 1215
End
Begin VB.Label Label2
BackColor = &H00404040&
Height = 380
Left = 840
TabIndex = 1
Top = 645
Width = 1180
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
Shape1.FillColor = &HFF&
Shape3.FillColor = &H808080
End If
If Button = vbLeftButton Then
Shape1.FillColor = &H808080
Shape3.FillColor = &HFF&
End If
End Sub

Um den Code zu nutzen, erstellen Sie sich mit einem Editor (ZBsp. Notepad) Dateien, die Sie wie beschrieben benennen und den jeweiligen Code hinein kopieren.
Rufen Sie dann die *.mak Datei aus dem Dateimanager auf oder starten Ihr VB-Programm und öffnen das Projekt.

Tipp-Download

Quelle :

Zurück zur Übersichtsseite