Not a Member Yet,
Click here to Register
How do you like the new design?






ID: 458
Viewed: 2680
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

How do I make my program to appear as its icon in the system tray when minimised? (just like Go!Zilla or NetSonic), may have to change private to public

Highlight all by clicking in box
<!---Declaration--->
none

Highlight All
<!---Code--->
'add a picture box Picture1 
'copy and paste this code
'set the form's ShowInTaskBar = false

Option Explicit

'public bas mod
Private Declare Function Shell_NotifyIcon _ Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
Private 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

Private Const NIF_ICON = &H2
Private Const NIF_MESSAGE = &H1
Private Const NIF_TIP = &H4
Private Const NIM_ADD = &H0
Private Const NIM_DELETE = &H2
Private Const NIM_MODIFY = &H1
Private Const WM_MOUSEMOVE = &H200

'Declare a Form Global Variable for the SysTray Icon Data
Private FrmSysTrayIcon As NOTIFYICONDATA
Private Sub Form_Load()
Picture1.Visible = False
'systray icon
'Create the System Tray Icon Object
'Image to appear in Tray
FrmSysTrayIcon.hIcon = Icon
'Handle of Object to recieve Tray Icon Events
FrmSysTrayIcon.hwnd = Picture1.hwnd
'Caption for Tray Icon, Must End with Chr(0)
FrmSysTrayIcon.szTip = Caption & Chr(0)
'Event Triggered When Interacting with Tray Icon
FrmSysTrayIcon.uCallbackMessage = WM_MOUSEMOVE
'Parts of Tray Icon we want to setup
FrmSysTrayIcon.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
'Unique Identifier
FrmSysTrayIcon.uID = 1
'Size of this Variable in Bytes.
FrmSysTrayIcon.cbSize = Len(FrmSysTrayIcon)
'Add the Icon to the System Tray
Shell_NotifyIcon NIM_ADD, FrmSysTrayIcon
'load listview

End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
'You can use the Hex of the X coord to findout if
'there was any MouseButton activity
'2D represents a Left Button Double Click
'0F represents mouse down (zero)
'1E represents mouse up
If Right(Hex(x), 2) = "2D" Then
'System tray Icon Double Clicked
'If the Window is Minimized, Restore it,
'Else Minimize it.
WindowState = IIf(WindowState = vbNormal, vbMinimized, vbNormal)
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
'Remove the Icon from the Tray on Exit
Shell_NotifyIcon NIM_DELETE, FrmSysTrayIcon
Unload Me
End Sub;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions