3个回答
推荐于2016-04-25 · 知道合伙人数码行家
可以叫我表哥
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:25897
获赞数:1464977
2010年毕业于北京化工大学北方学院计算机科学与技术专业毕业,学士学位,工程电子技术行业4年从业经验。
向TA提问 私信TA
关注
展开全部
方法1:编写菜单,然后利用菜单项的:Enabled属性或者Visible属性;
方法2:建立快捷菜单;右击出现菜单。
方法1的实现简单:
在创建菜单的时候,每个菜单项有1个”标题”和”名称”,其中名称其实是该菜单项的对象的名称,例如某菜单名称叫”abc”,那么:
abc. Visible=false 就使它不可见
abc. Visible= true 就使它可见
方法2:建立快捷菜单;右击出现菜单。
方法1的实现简单:
在创建菜单的时候,每个菜单项有1个”标题”和”名称”,其中名称其实是该菜单项的对象的名称,例如某菜单名称叫”abc”,那么:
abc. Visible=false 就使它不可见
abc. Visible= true 就使它可见
推荐于2018-03-14
展开全部
工具--菜单编辑器,建立以个你需要的菜单,名称为mainmenu,visble=false Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
Me.PopupMenu mainmenu
End If
End Sub
复制一下代码,窗体上右键即可看到结果
If Button = 2 Then
Me.PopupMenu mainmenu
End If
End Sub
复制一下代码,窗体上右键即可看到结果
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐于2017-12-15
展开全部
楼上这位大哥,人家是要托盘的菜单!菜单编辑器
'名称: Traymenu, 标题: 主菜单
'名称: menuexit, 标题: 退出
'然后把代码复制进去
Option Explicit
Const MAX_TOOLTIP As Integer = 64
Const NIF_ICON = &H2
Const NIF_MESSAGE = &H1
Const NIF_TIP = &H4
Const NIM_ADD = &H0
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_LBUTTONDBLCLK = &H203
Const WM_RBUTTONDOWN = &H204
Const WM_RBUTTONUP = &H205
Const WM_RBUTTONDBLCLK = &H206
Const SW_RESTORE = 9
Const SW_HIDE = 0
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Private nfIconData As NOTIFYICONDATA
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
nfIconData.cbSize = Len(nfIconData)
nfIconData.uID = vbNull
nfIconData.hwnd = Me.hwnd
nfIconData.uFlags = NIF_TIP Or NIF_MESSAGE Or NIF_ICON
nfIconData.uCallbackMessage = WM_MOUSEMOVE
nfIconData.hIcon = Me.Icon
nfIconData.szTip = "测试" & vbNullChar
Shell_NotifyIcon NIM_ADD, nfIconData
Me.Hide
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
If lMsg = WM_LBUTTONUP Then
Me.WindowState = 0
Me.Show
Else
If lMsg = WM_RBUTTONUP Then
PopupMenu Traymenu
End If
End If
End Sub
Private Sub menuexit_Click()
End
End Sub
'名称: Traymenu, 标题: 主菜单
'名称: menuexit, 标题: 退出
'然后把代码复制进去
Option Explicit
Const MAX_TOOLTIP As Integer = 64
Const NIF_ICON = &H2
Const NIF_MESSAGE = &H1
Const NIF_TIP = &H4
Const NIM_ADD = &H0
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_LBUTTONDBLCLK = &H203
Const WM_RBUTTONDOWN = &H204
Const WM_RBUTTONUP = &H205
Const WM_RBUTTONDBLCLK = &H206
Const SW_RESTORE = 9
Const SW_HIDE = 0
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Private nfIconData As NOTIFYICONDATA
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
nfIconData.cbSize = Len(nfIconData)
nfIconData.uID = vbNull
nfIconData.hwnd = Me.hwnd
nfIconData.uFlags = NIF_TIP Or NIF_MESSAGE Or NIF_ICON
nfIconData.uCallbackMessage = WM_MOUSEMOVE
nfIconData.hIcon = Me.Icon
nfIconData.szTip = "测试" & vbNullChar
Shell_NotifyIcon NIM_ADD, nfIconData
Me.Hide
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
If lMsg = WM_LBUTTONUP Then
Me.WindowState = 0
Me.Show
Else
If lMsg = WM_RBUTTONUP Then
PopupMenu Traymenu
End If
End If
End Sub
Private Sub menuexit_Click()
End
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询