Results 1 to 3 of 3

Thread: System Tray

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2001
    Location
    South Africa
    Posts
    35

    Question System Tray

    How do you add a 32bit icon to the sys tray

  2. #2
    Member
    Join Date
    Aug 2000
    Posts
    60
    In a 16x16 px icon there is no way that you would ever need 32bit colour.

    Grant French
    [email protected]

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    VB Code:
    1. 'Download the full source+pictures+... at [url]http://kpdteam.hypermart.net/download/tray.zip[/url]
    2. Private Type NOTIFYICONDATA
    3.     cbSize As Long
    4.     hWnd As Long
    5.     uId As Long
    6.     uFlags As Long
    7.     ucallbackMessage As Long
    8.     hIcon As Long
    9.     szTip As String * 64
    10. End Type
    11.  
    12. Private Const NIM_ADD = &H0
    13. Private Const NIM_MODIFY = &H1
    14. Private Const NIM_DELETE = &H2
    15. Private Const NIF_MESSAGE = &H1
    16. Private Const NIF_ICON = &H2
    17. Private Const NIF_TIP = &H4
    18.  
    19. Private Const WM_LBUTTONDBLCLK = &H203
    20. Private Const WM_LBUTTONDOWN = &H201
    21. Private Const WM_RBUTTONUP = &H205
    22.  
    23. Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    24. Dim TrayI As NOTIFYICONDATA
    25. Private Sub Form_Load()
    26.     TrayI.cbSize = Len(TrayI)
    27.     'Set the window's handle (this will be used to hook the specified window)
    28.     TrayI.hWnd = pichook.hWnd
    29.     'Application-defined identifier of the taskbar icon
    30.     TrayI.uId = 1&
    31.     'Set the flags
    32.     TrayI.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    33.     'Set the callback message
    34.     TrayI.ucallbackMessage = WM_LBUTTONDOWN
    35.     'Set the picture (must be an icon!)
    36.     TrayI.hIcon = imgIcon(2).Picture
    37.     'Set the tooltiptext
    38.     TrayI.szTip = "Recent" & Chr$(0)
    39.     'Create the icon
    40.     Shell_NotifyIcon NIM_ADD, TrayI
    41.  
    42.     Me.Hide
    43. End Sub
    44. Private Sub Form_Unload(Cancel As Integer)
    45.     'remove the icon
    46.     TrayI.cbSize = Len(TrayI)
    47.     TrayI.hWnd = pichook.hWnd
    48.     TrayI.uId = 1&
    49.     Shell_NotifyIcon NIM_DELETE, TrayI
    50.     End
    51. End Sub
    52. Private Sub mnuPop_Click(Index As Integer)
    53.     Select Case Index
    54.         Case 0
    55.             MsgBox "KPD-Team 1998" + Chr$(13) + "URL: [url]http://www.allapi.net/[/url]" + Chr$(13) + "E-Mail: [email][email protected][/email]", vbInformation + vbOKOnly
    56.         Case 2
    57.             Unload Me
    58.     End Select
    59. End Sub
    60. Private Sub pichook_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    61.     Msg = X / Screen.TwipsPerPixelX
    62.     If Msg = WM_LBUTTONDBLCLK Then
    63.         'Left button double click
    64.         mnuPop_Click 0
    65.     ElseIf Msg = WM_RBUTTONUP Then
    66.         'Right button click
    67.         Me.PopupMenu mnuPopUp
    68.     End If
    69. End Sub
    70. Private Sub Timer1_Timer()
    71.     Static Tek As Integer
    72.     'Animate the icon
    73.     Me.Icon = imgIcon(Tek).Picture
    74.     TrayI.hIcon = imgIcon(Tek).Picture
    75.     Tek = Tek + 1
    76.     If Tek = 3 Then Tek = 0
    77.     Shell_NotifyIcon NIM_MODIFY, TrayI
    78. End Sub
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

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