JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: How to add icon at the startup bar - bottom right corner Archived to Disk
To hide the program:
MainFormName.Visible=False
To add an icon (I believe all the stuff's here, I had to copy it from a program). Of course it requires a picture box.
' For Systray Icon
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 NID As NOTIFYICONDATA
Public Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid _
As NOTIFYICONDATA) As Boolean
Public Function SysTrayIcon(Optional ByVal fLoad As Boolean = True) As Boolean
On Error Resume Next
Err.Clear
' Define System tray icon
With NID
' Common To loading and unloading
.cbSize = Len(NID)
.hwnd = pctSysTray.hwnd
.uId = 1&
If fLoad Then
' Only Loading info
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.ucallbackMessage = WM_MOUSEMOVE
.hIcon = pctSysTray.hwnd
.szTip = "Tip" & Chr$(0)
End If
End With
If fLoad Then
' Load Sys Tray icon
Shell_NotifyIcon NIM_ADD, NID
Else
' Remove Sys Tray icon
Shell_NotifyIcon NIM_DELETE, NID
End If
SysTrayIcon = IIf(LenB(Err.Description) = 0, True, False)
End Function
' To handle the mouse events
Private Sub pctSysTray_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Show the menu, show options that are available
If Button = vbRightButton Then
PopupMenu menuTray, , , , menuFileRestore
End If
End Sub
|