Results 1 to 6 of 6

Thread: SysTray

  1. #1

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    How do I change the icon Of my Appl in the systray?

    Thanks

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    icon

    change your form icon...
    Form propeties
    Icon...
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

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

    Aaron Young Systray Sample???

    Hi,

    I am using Aaron Young sample to add My Appl to a systray and it is very good - BUT - i would like to change the icon in some event in my project. How Can i accomplish that???

    Best Regards

  4. #4
    Lively Member
    Join Date
    Jun 2000
    Posts
    67
    I think you shouldnt use an OCX to add an icon cause they give u little control u should use API calls

  5. #5

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

    I am NOT useing any OCX.
    I am using
    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 Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long

    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 WM_MOUSEMOVE = &H200
    Private Const WM_RBUTTONUP = &H205
    Private Const WM_LBUTTONDBLCLK = &H203
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_LBUTTONUP = &H202

    Private tTrayIcon As NOTIFYICONDATA

    Private Sub Form_Load()
    Picture1.Visible = False
    'Create a System Tray Icon
    With tTrayIcon
    'Set the Handle to the Icon you want to Display
    'This could be any Icon, for this example I'm using
    'The Icon assigned to the "Icon" Property of the Form.
    .hIcon = Icon
    'Tray Icon Messages are ReRouted to a Window Handle of
    'Your choice, typically it's wise to use a Picturebox
    'For this purpose.
    .hwnd = Picture1.hwnd
    'Set the "ToolTip" Caption that will Appear
    .szTip = Caption & Chr(0)
    'Set the Message used when Redirecting to the Specified
    'Window Handle
    .uCallbackMessage = WM_MOUSEMOVE
    'Set the Flags to add an Icon, ToolTip and Callback Message
    .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
    'Give the Icon a Unique ID, (This is unique to this Thread/App)
    .uID = 1
    'Set the Size of this Structure
    .cbSize = Len(tTrayIcon)
    End With
    'Add the Icon to the System Tray
    Shell_NotifyIcon NIM_ADD, tTrayIcon
    End Sub

    Private Sub Form_Resize()
    'Don't show the Form in the Taskbar when Minimized
    If WindowState = vbMinimized Then
    Hide
    WindowState = vbNormal
    End If
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    'Remove the System Tray Icon when the Form Unloads
    Shell_NotifyIcon NIM_DELETE, tTrayIcon
    End Sub

    Private Sub mnuExit_Click()
    'Unload the Form from the "Exit" PopupMenu Option
    Unload Me
    End Sub

    Private Sub mnuShow_Click()
    'Show the Form from the "Show" PopupMenu Option
    Show
    End Sub

    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'This is the Event that's passed the Callback Message Data
    'From the SystemTray Icon
    Select Case ScaleX(X, vbTwips, vbPixels)
    Case WM_LBUTTONDBLCLK
    'Double Click on SysTray Icon to Show Form
    Show
    Case WM_RBUTTONUP
    'Used for Displaying a Popup Menu
    Me.PopupMenu mnuPopup
    End Select
    End Sub

    Regards

  6. #6
    New Member
    Join Date
    Apr 2000
    Posts
    10

    Simple

    All you need to do is make another sub like ModifyIcon or whatever you want and copy exactly what is in form load except for

    Shell_NotifyIcon NIM_ADD, tTrayIcon

    and change it to

    Shell_NotifyIcon NIM_MODIFY, tTrayIcon

    also make sure to add Const NIM_MODIFY = &H1 in your declarations, you can change whatever you want with the icon in the modifyicon sub, good luck

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