CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: System Tray

  1. #1
    Join Date
    Sep 2001
    Posts
    4

    System Tray

    I wanted to have an application run in the System Tray. This application is a Visual basic exe and I want it to be residing in the System Tray. I searched the net and couldn't find anything related to it. I could find many articles that showed how to display an icon in the System Tray, but I was wondering how to reside the whole application in the System Tray?

    The Shell_NotifyIcon API function can create an icon in the system tray, is there any API function that would reside the whole application in the System Tray?

    Any help would be greatly appreciated.


  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: System Tray

    there's a free systray.ocx that'll do it for you at http://ebed.virtualave.net


  3. #3
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: System Tray

    The articles you speak of putting a Icon in the System Tray are what you are looking for. You incorporate the sample code supplied with the article with the code of your application. Then you create your .exe file

    John G

  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: System Tray

    Having created an icon in the system tray you need to set your application's main form's ShowIntaskbar member to false to prevent it being shown in the taskbar as well.




    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  5. #5
    Join Date
    Jul 2001
    Posts
    1

    Re: System Tray

    test


  6. #6
    Join Date
    Sep 2001
    Posts
    4

    Re: System Tray

    I can display the icon in the System Tray, the source code is attached herewith. I don't know how to use it to display the whole form? I have created a form Tray.frm and a module Tray.bas. I am confused as to how to make the iconFileName equal to a form or something else instead of ICON1 as mentioned below.


    Tray.bas


    option Explicit

    ' The API function declaration.

    public Declare Function Shell_NotifyIcon _
    Lib "shell32.dll" _
    Alias "Shell_NotifyIconA" _
    (byval dwMessage as Long, _
    lpData as NOTIFYICONDATA) as Long

    'Data type for icon data.

    public 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


    'The icon.

    Global Const ICON1 = "books01.ico"


    Global iconData as NOTIFYICONDATA

    Global iconFileName as string


    Global Const NIM_ADD = &H0

    Global Const NIM_MODIFY = &H1

    Global Const NIM_DELETE = &H2

    Global Const NIF_MESSAGE = &H1

    Global Const NIF_ICON = &H2

    Global Const NIF_TIP = &H4

    Global Const WM_MOUSEMOVE = &H200

    Global Const NIF_RBDOWN = 7740

    Global Const NIF_LBDOWN = 7695







    Tray.frm


    private Sub Form_Load()

    'Load the desired icon into the PictureBox.

    iconFileName = ICON1

    Picture1.Picture = LoadPicture(App.Path & "\" & iconFileName)

    'set up the NOTIFYICONDATA structure.

    iconData.cbSize = len(iconData)

    iconData.hWnd = Picture1.hWnd

    iconData.uID = 1&

    iconData.uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP

    iconData.uCallbackMessage = WM_MOUSEMOVE

    iconData.hIcon = Picture1.Picture

    iconData.szTip = "Tray Icon Demo" & Chr$(0)

    'Display the icon in the tray.

    Shell_NotifyIcon NIM_ADD, iconData

    End Sub

    private Sub mnuExit_Click()

    'Remove the icon from the tray and end the program.

    Shell_NotifyIcon NIM_DELETE, iconData

    End

    End Sub








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

Featured