Results 1 to 6 of 6

Thread: system tray

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2001
    Location
    earth
    Posts
    37

    system tray

    does any1 know where i'll find some tutorials about using the system tray in vb?

    tnx in adv
    bomberman

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    What do you want to do with it?

    Do you want to run an app from it?

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2001
    Location
    earth
    Posts
    37
    nah i want a right click menu thing so that i can launch proggies etc.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Then I would create a VB app, with a menu that has your proggie names on it, run it from the system tray, and use the right mouse click to popup your menu. Should be a piece of cake!

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2001
    Location
    earth
    Posts
    37
    tnx hack

    next time i should grow a brain

  6. #6
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Declarations

    Code:
    'Declare a user-defined variable to pass to the Shell_NotifyIcon
    'function.
    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
    
    'Declare the constants for the API function. These constants can be
    'found in the header file Shellapi.h.
    
    'The following constants are the messages sent to the
    'Shell_NotifyIcon function to add, modify, or delete an icon from the
    'taskbar status area.
    Private Const NIM_ADD = &H0
    Private Const NIM_MODIFY = &H1
    Private Const NIM_DELETE = &H2
    
    'The following constant is the message sent when a mouse event occurs
    'within the rectangular boundaries of the icon in the taskbar status
    'area.
    Private Const WM_MOUSEMOVE = &H200
    
    'The following constants are the flags that indicate the valid
    'members of the NOTIFYICONDATA data type.
    Private Const NIF_MESSAGE = &H1
    Private Const NIF_ICON = &H2
    Private Const NIF_TIP = &H4
    
    'The following constants are used to determine the mouse input on the
    'the icon in the taskbar status area.
    
    'Left-click constants.
    Private Const WM_LBUTTONDBLCLK = &H203   'Double-click
    Private Const WM_LBUTTONDOWN = &H201     'Button down
    Private Const WM_LBUTTONUP = &H202       'Button up
    
    'Right-click constants.
    Private Const WM_RBUTTONDBLCLK = &H206   'Double-click
    Private Const WM_RBUTTONDOWN = &H204     'Button down
    Private Const WM_RBUTTONUP = &H205       'Button up
    
    'Declare the API function call.
    Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    
    'Dimension a variable as the user-defined data type.
    Dim nid As NOTIFYICONDATA



    in form_load

    Code:
        nid.cbSize = Len(nid)
        nid.hWnd = frmChanger.hWnd
        nid.uId = vbNull
        nid.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
        nid.uCallBackMessage = WM_MOUSEMOVE
        nid.hIcon = frmChanger.Icon
        nid.szTip = "Background Changer" & vbNullChar
    
        'Call the Shell_NotifyIcon function to add the icon to the taskbar
        'status area.
        Shell_NotifyIcon NIM_ADD, nid
        Me.Hide
    in form_mousemove

    Code:
        Dim msg As Long
        Dim sFilter As String
        msg = X / Screen.TwipsPerPixelX
        Select Case msg
            Case WM_LBUTTONDOWN
            Case WM_LBUTTONUP
            Case WM_LBUTTONDBLCLK
            Case WM_RBUTTONDOWN
                PopupMenu mnuSystray
            Case WM_RBUTTONUP
            Case WM_RBUTTONDBLCLK
        End Select
    in form_unload / frm_terminate...

    Code:
    Shell_NotifyIcon NIM_DELETE, nid
    This will create an icon (of form1) in the systray. When the user rightclicks on it, it will bring up the mnusystray menu created using the form menu editor.

    Hope this helps
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


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