Results 1 to 5 of 5

Thread: Tray Icons

  1. #1

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249

    Tray Icons

    Hi,
    I add my app to the SysTray and i have my icon, I olso change the icon BUT when i change the icon i dont get the Cllback Message !. Am i missing somthing here?.



    Call ChangeTrayIcon Form1.picIdle.Picture


    Public Sub ChangeTrayIcon(vIcon As Variant)

    With MyTrayIcon
    .hIcon = vIcon
    .cbSize = Len(tTrayIcon)
    End With
    Shell_NotifyIcon NIM_MODIFY, MyTrayIcon

    End Sub

    Regards

  2. #2
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    what do you mean by callback message. Are you talking about a return value?

  3. #3
    Why not just use an ActiveX control, like ASTI (somewhere on crappy Geocities) or the DevPower System Tray Icon (my favorite) http://www.devpower/

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    like this:

    Code:
    
    Option Explicit
    
    
     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 NIM_DELETE = &H2
      Private Const NIM_MODIFY = &H1
      Private Const NIM_ADD = &H0
      Private Const NIF_ICON = &H2
      Private Const NIF_MESSAGE = &H1
      Private Const NIF_TIP = &H4
      Private Const GWL_WNDPROC = (-4)
      Private Const IDI_APPLICATION = 32512&
      Private Const WM_USER = &H400
      Private Const WM_COMMAND = &H111
    ''these are for the icon-in-system-tray
    Private Const NIF_DOALL = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
    Private Const WM_MOUSEMOVE = &H200
    Private Const WM_LBUTTONDBLCLK = &H203
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_RBUTTONDOWN = &H204
    Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
    
    Private Const VK_LBUTTON = &H1
    Private Const VK_RBUTTON = &H2
    
    
    
    Private Sub CreateIcon()
      Dim erg
      Dim Tic As NOTIFYICONDATA
      Tic.cbSize = Len(Tic)
      Tic.hwnd = Picture1.hwnd
      Tic.uID = 1&
      Tic.uFlags = NIF_DOALL
      Tic.uCallbackMessage = WM_MOUSEMOVE
      Tic.hIcon = Picture1.Picture
      'Tic.szTip = App.Title & Chr$(0)
      Tic.szTip = Me.Caption & Chr$(0)
      erg = Shell_NotifyIcon(NIM_ADD, Tic)
    End Sub
    
    
    
    Private Sub Command1_Click()
      CreateIcon
      Me.Hide
      
    End Sub
    
    
    Private Sub DeleteIcon()
      Dim erg
      Dim Tic As NOTIFYICONDATA
      Tic.cbSize = Len(Tic)
      Tic.hwnd = Picture1.hwnd
      Tic.uID = 1&
      erg = Shell_NotifyIcon(NIM_DELETE, Tic)
    End Sub
    
    
    Private Sub Form_Load()
    Picture1.Picture = Me.Icon
    End Sub
    
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)
      X = X / Screen.TwipsPerPixelX
      Select Case X
        Case WM_LBUTTONDOWN
          'Caption = "Left Click"
          Me.Show
          DeleteIcon
        
          
          
        Case WM_RBUTTONDOWN
        
          'MsgBox "Right Click"
          
          Me.Show
          DeleteIcon
          
        Case WM_MOUSEMOVE
          'Caption = "Move"
        Case WM_LBUTTONDBLCLK
          'Caption = "Double Click"
          Me.Show
          DeleteIcon
        
          
      
    
        End Select
    End Sub
    Mark
    -------------------

  5. #5

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    Hi,
    Caalback mean? - When you get control in - mousemove or mouseclick on the pictur1.hwnd - but if i change the tray icon to picture2 then the callback msg stop...

    Regards

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