VB这段代码如何修改,可以双击托盘图标打开程序。

窗体上创建一个菜单标题为“文件”名称为sys的菜单设置不可见有两个子菜单“退出”NMexit“显示”NMshowOptionExplicitConstMAX_TOOLTI... 窗体上创建一个菜单
标题为“文件” 名称为sys的菜单 设置不可见
有两个子菜单 “退出” NMexit
“显示” NMshow
Option Explicit
Const MAX_TOOLTIP As Integer = 60
Const NIF_ICON = &H2
Const NIF_MESSAGE = &H1
Const NIF_TIO = &H4
Const NIM_ADD = &H0
Const NIM_DELETE = &H2
Const WM_MOUSEMOVE = &H200
Const WM_LBUTTONUP = &H202
Const WM_RBUTTONUP = &H205
Private Type NOTIFYICONDATA
cbSize As Long
bwnd As Long
uID As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * MAX_TOOLTIP
End Type
'声明 Shell_NotifyIcon 函数
Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, IpData As NOTIFYICONDATA) As Long
Private nfIconData As NOTIFYICONDATA

Private Sub Form_Load()
nfIconData.bwnd = Me.hWnd
nfIconData.uID = Me.Icon
nfIconData.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIO
nfIconData.uCallBackMessage = WM_MOUSEMOVE
nfIconData.hIcon = Me.Icon.Handle
nfIconData.szTip = "用vb制作的 QQ" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
End Sub
'窗体鼠标移动时间
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim IMsg As Single
IMsg = X / Screen.TwipsPerPixelX
If IMsg = WM_RBUTTONUP Or IMsg = WM_RBUTTONUP Then Me.PopupMenu sys
End Sub
'退出菜单
Private Sub NMexit_Click()
End
End Sub
'现实菜单
Private Sub NMshow_Click()
Me.Visible = True
Me.WindowState = 0
End Sub
如何双击托盘图标打开程序,求高手帮助。
展开
 我来答
zgwxm
2011-12-19 · 经典歌曲、名人名家歌曲视频
zgwxm
采纳数:1792 获赞数:21142

向TA提问 私信TA
展开全部
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim IMsg As Single
IMsg = X / Screen.TwipsPerPixelX
If IMsg = WM_RBUTTONUP Or IMsg = WM_RBUTTONUP Then Me.PopupMenu sys
'加下面一句!
If IMsg = &H203 Then Me.Show
End Sub
请参阅我的博客:http://hi.baidu.com/zgmg/blog/item/1b965109731ffcb12eddd4a5.html
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式