Results 1 to 4 of 4

Thread: System Tray Icons W/menus... Could ANYONE PLEASE HELP ME..

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Location
    Mi
    Posts
    5

    Post

    I've have seen how to add an icon to the system tray, but is there a way of adding the icon with a menu (E.I. when you right click it) such as the toolbar with out using c++... thanks.

    ------------------

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    No problem, add a Picturebox to a Form, Create a Menu Called mnuPopup and Set it's Visible Property to False, (Uncheck it), then add this code to the Form..
    Code:
    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 NIM_MODIFY = &H1
    Private Const WM_MOUSEMOVE = &H200
    
    Private tTrayIcon As NOTIFYICONDATA
    
    Private Sub Form_Load()
        'Create a Tray Icon
        Picture1.Visible = False
        With tTrayIcon
            .hIcon = Icon
            .hwnd = Picture1.hwnd
            .szTip = "My Tray Icon" & Chr(0)
            .uCallbackMessage = WM_MOUSEMOVE
            .uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
            .uID = 1
            .cbSize = Len(tTrayIcon)
        End With
        Shell_NotifyIcon NIM_ADD, tTrayIcon
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        'Remove the Tray Icon
        Shell_NotifyIcon NIM_DELETE, tTrayIcon
    End Sub
    
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Right(Hex(X), 2) = "4B" Then
            'Right Clicked Tray Icon
            'Show Popup Menu
            PopupMenu mnuPopup
        End If
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


    [This message has been edited by Aaron Young (edited 11-05-1999).]

  3. #3
    New Member
    Join Date
    Dec 1999
    Location
    Espinho/Portugal
    Posts
    1

    Post

    there's an easier way. Do you have the 2 Visual studio cd's? if you do, find systray.vbp on the 2nd cd and compile it to your windows\system directory. then just add the systray component to your project.

    ------------------
    [-The Punisher-]

  4. #4
    Lively Member
    Join Date
    Oct 1999
    Posts
    67

    Post

    you wouldn't stick the ocx on a web page would you please , for download
    Thanks

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