VB如何置托盘图标?

如何???急急急超急急急急急急点击图标如何让他再弹出?... 如何???



超急


急急急
点击图标如何让他再弹出?
展开
 我来答
百度网友7634fbe
2009-06-30
知道答主
回答量:1
采纳率:0%
帮助的人:0
展开全部
下面的代码放到一个标准模块中:

Option Explicit

Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4
Private Const NIF_STATE = &H8
Private Const NIF_INFO = &H10
Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const NIM_SETFOCUS = &H3
Private Const NIM_SETVERSION = &H4
Private Const NIM_VERSION = &H5
Private Const WM_USER As Long = &H400
Private Const NIN_BALLOONSHOW = (WM_USER + 2)
Private Const NIN_BALLOONHIDE = (WM_USER + 3)
Private Const NIN_BALLOONTIMEOUT = (WM_USER + 4)
Private Const NIN_BALLOONUSERCLICK = (WM_USER + 5)
Private Const NOTIFYICON_VERSION = 3
Private Const NIS_HIDDEN = &H1
Private Const NIS_SHAREDICON = &H2
Private Const WM_NOTIFY As Long = &H4E
Private Const WM_COMMAND As Long = &H111
Private Const WM_CLOSE As Long = &H10
Private Const WM_MOUSEMOVE As Long = &H200
Private Const WM_LBUTTONDOWN As Long = &H201
Private Const WM_LBUTTONUP As Long = &H202
Private Const WM_LBUTTONDBLCLK As Long = &H203
Private Const WM_MBUTTONDOWN As Long = &H207
Private Const WM_MBUTTONUP As Long = &H208
Private Const WM_MBUTTONDBLCLK As Long = &H209
Private Const WM_RBUTTONDOWN As Long = &H204
Private Const WM_RBUTTONUP As Long = &H205
Private Const WM_RBUTTONDBLCLK As Long = &H206

Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long

Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 128
dwState As Long
dwStateMask As Long
szInfo As String * 256
uTimeoutAndVersion As Long
szInfoTitle As String * 64
dwInfoFlags As Long
End Type

'鼠标事件
Public Enum TrayRetunEventEnum
NM_MOUSEMOVE = &H200 '鼠标移过
NM_LBUTTONDOWN = &H201 '鼠标左键按下
NM_LBUTTONUP = &H202 '鼠标右键弹起
NM_LDBCLICK = &H203 '鼠标左键双击
NM_RBUTTONDOWN = &H204 '鼠标右键按下
NM_RBUTTONUP = &H205 '鼠标右键弹起
NM_RDBCLICK = &H206 '鼠标右键双击
NM_MBUTTONDOWN = &H207 '鼠标中键按下
NM_MBUTTONUP = &H208 '鼠标中键弹起
NM_MDBCLICK = &H209 '鼠标中键双击
NM_BALLONCLICK = (WM_USER + 5) '气泡被单击
End Enum

Private m_Tray As NOTIFYICONDATA
Private m_Load As Boolean

Public Function AddTrayIcon(ByVal hWnd As Long, ByVal ToolTip As String, ByVal hIcon As Long) As Long
With m_Tray
.cbSize = Len(m_Tray)
.hWnd = hWnd
.uID = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = hIcon
.szTip = ToolTip & vbNullChar
End With
AddTrayIcon = Shell_NotifyIcon(NIM_ADD, m_Tray)
End Function

Public Property Get Tips() As String
Tips = m_Tray.szTip
End Property

Public Property Let Tips(ByVal NewValue As String)
m_Tray.szTip = NewValue & vbNullChar
Shell_NotifyIcon NIM_MODIFY, m_Tray
End Property

Public Property Get IconHandle() As Long
IconHandle = m_Tray.hIcon
End Property

Public Property Let IconHandle(ByVal NewValue As Long)
m_Tray.hIcon = IconHandle
Shell_NotifyIcon NIM_MODIFY, m_Tray
End Property

Public Function RemoveIcon() As Long
Shell_NotifyIcon NIM_DELETE, m_Tray
End Function

'然后你在窗口添加一个Picture1控件
窗口的代码
Private Sub Form_Load()
Call AddTrayIcon(Picture1.hWnd, "提示文字", Me.Icon.Handle)
End SUb

Private Sub Form_Unload()
Call RemoveIcon '移除托盘图标
End Sub
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
微软专家张海
2009-06-30 · TA获得超过748个赞
知道小有建树答主
回答量:564
采纳率:100%
帮助的人:0
展开全部
就是设置form的图标
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式