Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

如何将软件图标添加到托盘中

时 间: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源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助