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
如何双击托盘图标打开程序,求高手帮助。 展开
标题为“文件” 名称为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
如何双击托盘图标打开程序,求高手帮助。 展开
展开全部
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
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 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询