vb程序弹出式菜单在程序中要用什么方法显示
发布网友
发布时间:2022-05-19 05:33
我来回答
共1个回答
热心网友
时间:2024-03-04 23:43
......
不会啊
用MouseUp事件里的
Button参数
1表示左键
2表示右键
建一个菜单
vbFile
子菜单vbRight:
(右键点击窗体
就会弹出
vbFile下的几个子菜单了)
Private
Sub
Form_Load()
vbFile.Visible
=
False
End
Sub
Private
Sub
Form_MouseUp(Button
As
Integer,
Shift
As
Integer,
X
As
Single,
Y
As
Single)
Select
Case
Button
Case
1
Print
"点击了左键"
Case
2
Print
"点击了右键"
PopupMenu
vbFile
End
Select
End
Sub
----------------------------
Private
Sub
Text1_MouseDown(Button
As
Integer,
Shift
As
Integer,
X
As
Single,
Y
As
Single)
If
Button
=
1
Then
PopupMenu
color,
4
Or
0
End
If
End
Sub
是对的。
建议改成MouseUp事件,因为你看正常的弹出菜单
都是鼠标键弹起来出现的
才发现
你是想要把系统的右键弹出式菜单屏蔽吧
如下代码即可(把相应代码改成你想要的)
Private
Sub
Text1_MouseUp(Button
As
Integer,
Shift
As
Integer,
X
As
Single,
Y
As
Single)
If
Button
=
1
Then
PopupMenu
color,
0
Or
4'左键所触发的内容
End
If
If
Button
=
2
Then'右键所触发的内容
Text1.Enabled
=
False
Text1.Enabled
=
True
PopupMenu
color,
0
Or
4
End
If
End
Sub