| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 681 人关注过本帖
标题:VB.NET高手向這看
只看楼主 加入收藏
adair
Rank: 3Rank: 3
等 级:新手上路
威 望:9
帖 子:250
专家分:0
注 册:2005-9-3
收藏
 问题点数:0 回复次数:3 
VB.NET高手向這看
我在視窗中放置了一個BUTTON1,現我想用這種方試激發BUTTON1的事件:同時按下SHIFT鍵和鼠標左鍵.請問怎麼樣實現.請給出在.NET中調試通過的代碼.

不勝感激!!!!!
搜索更多相关主题的帖子: NET 
2005-09-09 18:28
adair
Rank: 3Rank: 3
等 级:新手上路
威 望:9
帖 子:250
专家分:0
注 册:2005-9-3
收藏
得分:0 
在線等等呀.謝謝!

********年轻无极限******** 要時刻相信你自己,不要被自己打敗
2005-09-09 18:29
quxch
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2005-1-4
收藏
得分:0 

我写了一段,是通过各个事件来控制的,但是还有一个问题没有解决,就是在别的控键上点击鼠标还没有办法激活窗体的鼠标事件,你可以先试试,如果控键少的话,可以试着在每个控键上写一下鼠标点击事件就可以完成这个功能了!

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

2005-09-12 14:17
adair
Rank: 3Rank: 3
等 级:新手上路
威 望:9
帖 子:250
专家分:0
注 册:2005-9-3
收藏
得分:0 

謝謝你的提示.我編出了一個,感覺很爽. 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


********年轻无极限******** 要時刻相信你自己,不要被自己打敗
2005-09-14 21:04
快速回复:VB.NET高手向這看
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027312 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved