不勝感激!!!!!
我写了一段,是通过各个事件来控制的,但是还有一个问题没有解决,就是在别的控键上点击鼠标还没有办法激活窗体的鼠标事件,你可以先试试,如果控键少的话,可以试着在每个控键上写一下鼠标点击事件就可以完成这个功能了!
Dim strKey As String = "" Dim strMouse As String = "" Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("a") End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click MsgBox("b") End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then strMouse = "left" If strKey = "shift" Then Button1_Click(sender, e) strKey = "" strMouse = "" End If ElseIf e.Button = MouseButtons.Right Then strMouse = "right" If strKey = "shift" Then Button2_Click(sender, e) strKey = "" strMouse = "" End If End If End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp strMouse = "" 'MsgBox("a") End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown If e.KeyCode = 16 Then strKey = "shift" End If If strMouse = "left" Then Button1_Click(sender, e) strKey = "" strMouse = "" ElseIf strMouse = "right" Then Button2_Click(sender, e) strKey = "" strMouse = "" End If End Sub
Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp strKey = "" End Sub
謝謝你的提示.我編出了一個,感覺很爽. Dim strkey As Boolean
Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown If strkey = True Then strkey = False MsgBox("") End If End Sub
Private Sub Button1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyDown If e.Shift = True Then strkey = True End If End Sub
Private Sub Button1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyUp strkey = False End Sub