Results 1 to 3 of 3

Thread: Refresh System Tray

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2001
    Posts
    15

    Unhappy

    Hi,

    When I exit from a program that runs in the tray,
    the tray isn't refreshing itself untill I move over
    the tray with the mouse.
    How can I refresh the tray within the code ?


    TIA

    Eddie
    Last edited by adiad; Mar 30th, 2001 at 02:40 AM.

  2. #2
    Addicted Member Xdream's Avatar
    Join Date
    Mar 2001
    Location
    Switzerland
    Posts
    194
    Hi Eddi

    I don't know the variables you're using, but in my systemtray program, I'm using the following code when the form unloads:

    Code:
    Sub Form_Unload(Cancel as Integer)  'your unload sub        
            '...your stuff
            TrayIcon.cbSize = Len(TrayIcon)
            TrayIcon.hwnd = Me.hwnd
            TrayIcon.uId = vbNull
            Call Shell_NotifyIcon(NIM_DELETE, TrayIcon)
            Unload Me
            End
    End Sub
    I didn't try if 'Call Shell_NotifyIcon(NIM_DELETE, yourtrayicon)' is enough or if you really need all the code(I copied it, too)...

    Hope you can use this
    Last edited by Xdream; Mar 31st, 2001 at 11:22 AM.

  3. #3
    Addicted Member Xdream's Avatar
    Join Date
    Mar 2001
    Location
    Switzerland
    Posts
    194
    ...and here's the code I'm using in my module...
    Code:
    '----- Systray
    Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    
    Public Const WM_LBUTTONDBLCLK = &H203
    Public Const WM_RBUTTONUP = &H205
    
    Public Const NIM_ADD = &H0
    Public Const NIM_MODIFY = &H1
    Public Const NIF_MESSAGE = &H1
    Public Const NIM_DELETE = &H2
    Public Const NIF_ICON = &H2
    Public Const NIF_TIP = &H4
    
    Public Const WM_MOUSEMOVE = &H200
    
    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 TrayIcon As NOTIFYICONDATA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width