如何将软件图标添加到托盘中
时 间:2007-11-14 19:53:04
作 者:刘贵平 ID:14 城市:长沙
摘 要:如何将软件图标添加到托盘中
正 文:
如何实现安装软件以后,想任务栏上自动加上该程序的图标吗?运行等程序以后,WINDOWS任务栏上将自动出现该程序的图标.
实现过程如下:
1\新建一个数据库,创建一个窗体,默认名称属性为FORM1
2\打开菜单编辑器,在FORM1窗体中添加一个名为SYS的主菜单,并在该菜单下建立3个子菜单.
3\程序代码如下:
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_LBUTTONUP = &H202
Const WM_RBUTTONUP = &H205
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
'声明Shell_notifyicon函数
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_Load()
nfIconData.hwnd = Me.hwnd
nfIconData.uID = Me.Icon
nfIconData.uFlags = NIF_ICON or NIF_MESSAGE or NIF_TIP
nfIconData.uCallbackMessage = WM_MOUSEMOVE
nfIconData.hIcon = Me.Icon.Handle
nfIconData.szTip = "System Tray Example" & vbNullChar
nfIconData.cbSize = Len(nfIconData)
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
Me.Visible = False
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_RBUTTONUP or lMsg = WM_LBUTTONUP Then Me.PopupMenu sys
End Sub
Private Sub move_Click()
Call Shell_NotifyIcon(NIM_Delete, nfIconData)
End Sub
Private Sub show_Click()
Me.Visible = True
End Sub
Private Sub exit_Click()
Unload Me
End Sub
4\根据此代码可在系统托盘中增加一个光驱按纽
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- 【Access Inputbo...(12.23)
- 【Access Dsum示例】...(12.16)

学习心得
最新文章
- 仓库管理实战课程(9)-开发往来单...(04.02)
- 仓库管理实战课程(8)-商品信息功...(04.01)
- 仓库管理实战课程(7)-链接表(03.31)
- 仓库管理实战课程(6)-创建查询(03.29)
- 仓库管理实战课程(5)-字段属性(03.27)
- 设备装配出入库管理系统;基于Acc...(03.24)
- 仓库管理实战课程(4)-建表操作(03.22)
- 仓库管理实战课程(3)-需求设计说...(03.19)
- 仓库管理实战课程(2)-软件背景和...(03.18)
- 仓库管理实战课程(1)-讲师介绍(03.16)