'自已加一个Timer,定时更改图标 '把下面的内容贴到记事本,保存为Form1.frmVERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 1665 ClientLeft = 2160 ClientTop = 1650 ClientWidth = 2940 Icon = "TBIcon.frx":0000 LinkTopic = "Form1" PaletteMode = 1 'UseZOrder ScaleHeight = 1665 ScaleWidth = 2940 ShowInTaskbar = 0 'False Begin VB.PictureBox Picture1 Height = 495 Left = 120 ScaleHeight = 435 ScaleWidth = 435 TabIndex = 0 Top = 1680 Visible = 0 'False Width = 495 End Begin VB.Menu xx Caption = "PopupMenu" Visible = 0 'False Begin VB.Menu mnu_hide Caption = "隐藏" End Begin VB.Menu mnu_show Caption = "显示" End Begin VB.Menu mnu_answer Caption = "回复消息" End Begin VB.Menu mnu_space Caption = "-" End Begin VB.Menu Menu Caption = "退出" Index = 0 End End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option ExplicitPrivate Type NOTIFYICONDATA cbSize As Long hWnd As Long uId As Long uFlags As Long ucallbackMessage As Long hIcon As Long szTip As String * 64 End TypePrivate Const NIM_ADD = &H0 Private Const NIM_MODIFY = &H1 Private Const NIM_DELETE = &H2 Private Const WM_MOUSEMOVE = &H200 Private Const NIF_MESSAGE = &H1 Private Const NIF_ICON = &H2 Private Const NIF_TIP = &H4Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean Dim t As NOTIFYICONDATAPrivate Sub Form_Load() t.cbSize = Len(t) t.hWnd = Picture1.hWnd t.uId = 1& t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE t.ucallbackMessage = WM_MOUSEMOVE t.hIcon = Form1.Icon t.szTip = "消息服务器" & Chr$(0) Shell_NotifyIcon NIM_ADD, t App.TaskVisible = False End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) t.cbSize = Len(t) t.hWnd = Picture1.hWnd t.uId = 1& Shell_NotifyIcon NIM_DELETE, t End SubPrivate Sub Menu_Click(Index As Integer) Unload Me End SubPrivate Sub mnu_hide_Click() Me.Hide End SubPrivate Sub mnu_show_Click() Me.Show End SubPrivate Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Hex(X) = "1E3C" Then Me.PopupMenu xx End If End Sub
能给个例子么?谢谢了
'把下面的内容贴到记事本,保存为Form1.frmVERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1665
ClientLeft = 2160
ClientTop = 1650
ClientWidth = 2940
Icon = "TBIcon.frx":0000
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 1665
ScaleWidth = 2940
ShowInTaskbar = 0 'False
Begin VB.PictureBox Picture1
Height = 495
Left = 120
ScaleHeight = 435
ScaleWidth = 435
TabIndex = 0
Top = 1680
Visible = 0 'False
Width = 495
End
Begin VB.Menu xx
Caption = "PopupMenu"
Visible = 0 'False
Begin VB.Menu mnu_hide
Caption = "隐藏"
End
Begin VB.Menu mnu_show
Caption = "显示"
End
Begin VB.Menu mnu_answer
Caption = "回复消息"
End
Begin VB.Menu mnu_space
Caption = "-"
End
Begin VB.Menu Menu
Caption = "退出"
Index = 0
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option ExplicitPrivate Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uId As Long
uFlags As Long
ucallbackMessage As Long
hIcon As Long
szTip As String * 64
End TypePrivate Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const WM_MOUSEMOVE = &H200
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Dim t As NOTIFYICONDATAPrivate Sub Form_Load()
t.cbSize = Len(t)
t.hWnd = Picture1.hWnd
t.uId = 1&
t.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
t.ucallbackMessage = WM_MOUSEMOVE
t.hIcon = Form1.Icon
t.szTip = "消息服务器" & Chr$(0)
Shell_NotifyIcon NIM_ADD, t
App.TaskVisible = False
End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
t.cbSize = Len(t)
t.hWnd = Picture1.hWnd
t.uId = 1&
Shell_NotifyIcon NIM_DELETE, t
End SubPrivate Sub Menu_Click(Index As Integer)
Unload Me
End SubPrivate Sub mnu_hide_Click()
Me.Hide
End SubPrivate Sub mnu_show_Click()
Me.Show
End SubPrivate Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Hex(X) = "1E3C" Then
Me.PopupMenu xx
End If
End Sub
能符合你的要求
FORM的LOAD 中加入ME。HIDE
我给你发例子