Você vai precisar criar um objeto Picture com a foto do icone que vai aparecer no Tray, chame-o de Picture1.
No Form_Activate do seu programa coloque o código:
Do
DoEvents
If Me.WindowState = 1 Then
Load frmTray 'Esse aqui é o formulário onde tem que estar o Objeto Picture e nde vai estar a maior parte do código
me.hide
End if
Loop
'Coloque isso aqui num Módulo:
Public 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 Type
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const WM_MOUSEMOVE = &H200
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Declare Function ShellExecute Lib "shell32" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public t As NOTIFYICONDATA
No frmTray cole:
Private 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 = Picture1.Picture
t.szTip = me.Caption & " ..." & Chr$(0) 'No lugar de me.caption coloque o nome do Programa
Shell_NotifyIcon NIM_ADD, t
Me.Hide
App.TaskVisible = False
End Sub
Private 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 Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Hex(X) = "1E3C" Or Hex(X) = "1E0F" Then
frmPrograma.show 'Aqui no lugar de frmPrograma vc coloca o nome do formulário do seu programa
unload Tray
End If
End Sub
Pronto, é isso, esse código é de outra pessoa, mas não me lembro o nome agora...
Dê uma lida no código antes de colocar no programa pra funcionar direitinho.
T+
Calel