• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

system tray

How do you put an application in the
system tray?  I think it is called the
system tray.  I want to put my application
in the lower right corner of the screen.
The area right next to the system time.

the application is an application i wrote
myself.  i would like the application
to put itself in the system tray.  I don't
want to have to do it manually.
0
ueihp
Asked:
ueihp
1 Solution
 
mcriderCommented:
Read this Microsoft KB Article...

HOWTO: Use the System Tray Directly from Visual Basic
http://support.microsoft.com/support/kb/articles/Q176/0/85.ASP

Cheers!


0
 
Erick37Commented:
Here is another site which demonstrates how to do this. Code is included:

http://www.spnc.demon.co.uk/vb/vbtray.htm
0
 
JuiletteCommented:
Option Explicit

'systray icon delcares and functions
'
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

'You can use NIM_MODIFY in conjunction with changing the
'SysTrayIcon.hIcon property to give the effect of
'an animated System Tray Icon.

'Declare a Variable for the SysTray Icon Data
Private SysTrayIcon As NOTIFYICONDATA

Private Sub Form_Load()

'Create the System Tray Icon Object

        'Image to appear in Tray
        SysTrayIcon.hIcon = Icon
        'Handle of Object to recieve Tray Icon Events
         SysTrayIcon.hwnd = picSysTray.hwnd
        'Caption for Tray Icon, Must End with Chr(0)
        SysTrayIcon.szTip = Caption & Chr(0)
        'Event Triggered When Interacting with Tray Icon
        SysTrayIcon.uCallbackMessage = WM_MOUSEMOVE
        'Parts of Tray Icon we want to setup
        SysTrayIcon.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
        'Unique Identifier
        SysTrayIcon.uID = 1
        'Size of this Variable in Bytes.
        SysTrayIcon.cbSize = Len(SysTrayIcon)
     
    'Add the Icon to the System Tray
    Shell_NotifyIcon NIM_ADD, SysTrayIcon
End Sub

Private Sub Form_Unload(Cancel As Integer)
Shell_NotifyIcon 2, SysTrayIcon
   
      End

End Sub

Private Sub picSysTray_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Select Case Right(Hex(X), 2)
        Case "00"  ' Mouse Move
      '<<< Put Your Code Here >>>
         
        Case "0F"  ' Left Mouse Down
      '<<< Put Your Code Here >>>
        'If the Window is Minimized, Restore it else Minimize it.
        WindowState = IIf(WindowState = vbNormal, _
                            vbMinimized, vbNormal)
     
        Case "1E"  ' Left Mouse Up
      '<<< Put Your Code Here >>>
     
        Case "3C"  ' Right Mouse Down
      '<<< Put Your Code Here >>>
         
        Case "4B"  ' Right Mouse Up
      '<<< Put Your Code Here >>>
         
        Case "2D"  ' Double Left Click
      '<<< Put Your Code Here >>>
         
        Case "5A"  ' Double Right Click
      '<<< Put Your Code Here >>>
  End Select
End Sub


0
 
ueihpAuthor Commented:
thanks everyone.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now