如何将软件图标添加到托盘中
时 间: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)
- 【Access DCount示...(12.02)
- Access对子窗体数据进行批...(10.30)
- 最精简的组合框行来源数据快速输...(10.25)
- Access仿平台的多值选择器...(10.24)
- 【Access日期区间段查询】...(10.22)
- 【Access源码示例】VBA...(10.12)
- Access累乘示例,Acce...(10.09)
- 数值8.88,把整数8去掉,转...(10.08)
- 【Access自定义函数】一个...(09.30)
学习心得
最新文章
- Microsoft ActiveX...(12.04)
- 把一种单位的数量,换算成多个单位的...(12.03)
- 【Access DCount示例】...(12.02)
- Access判断多条明细的配方或订...(11.30)
- 如何让后台数据库在局域网共享时,且...(11.29)
- 【Access月初月末日期设置方法...(11.29)
- 【Access IIF函数嵌套示例...(11.26)
- Access快速开发平台--使用组...(11.25)
- Access快速开发平台--对上传...(11.22)
- Access快速开发平台企业版--...(11.18)