CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Feb 2011
    Posts
    39

    Question System Tray Application

    Hello all,

    How does one begin to program system tray applications? I assume that we don't need a CFrameWnd class at all and we only initialize a CWinApp class. I still have no idea how to begin. Also, google searches do not give me the info i need. There are many headers out there which i can use but i'm keen on learning it.

    Thanks in advance.

  2. #2
    Join Date
    Dec 2004
    Location
    Ann Arbor, MI
    Posts
    281

    Re: System Tray Application

    You at least need a window to receive notifications.

    Read up on Shell_NotifyIcon, that along with NOTIFYICONDATA struct should give you a good starting point.

    Make sure to remove your icon from the system tray before your application exits, otherwise it will hang around forever.
    --EJMW

  3. #3
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: System Tray Application

    Just search the forum with 'TrayIcon' keyword. You will get a lot of stuffs.
    ◄◄ hypheni ►►

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: System Tray Application

    This thread has a class I wrote attached you can use to make it simple.

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: System Tray Application

    How does one begin to program system tray applications?
    Could you please define "system tray application." If this is what I understand, this is an application like any other one, with just a system tray icon added and handled properly. So a good starting point is to develop your application without system tray icon, and add the icon support later.
    Last edited by Igor Vartanov; May 22nd, 2011 at 04:05 AM.
    Best regards,
    Igor

  6. #6
    Join Date
    Feb 2011
    Posts
    39

    Re: System Tray Application

    Thank you ejmw, hypheni, Skizmo and Igor for replying and sorry for the late reply!

    Igor, that's a very appropriate sketch of what i've done. I just need to incorporate the system tray icon.

    Update: The icon appears in the tray (i'm using IDI_QUESTION because i haven't designed an .ico yet) but quickly disappears as soon as i roll the mouse over it.

    I still need more info unfortunately so i'd be extremely grateful for any leads.
    Thanks.

  7. #7
    Join Date
    Feb 2011
    Posts
    39

    Re: System Tray Application

    I just got the icon to stay. However, I'm still clueless about capturing messages like WM_RBUTTONDOWN and displaying a menu for it.

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: System Tray Application

    Search the forum for "system tray" and "tray icon", and you're gonna find lots of code snippets. But Shell_NotifyIcon should be carefully read first anyway.
    Best regards,
    Igor

  9. #9
    Join Date
    Feb 2011
    Posts
    39

    Re: System Tray Application

    Thanks Igor, I tried searching with "system tray WM_" and i found out that if I

    1.) #define WM_NOTIFYICON WM_USER+1
    2.) nid.uCallbackMessage = WM_NOTIFYICON
    3.) ON_MESSAGE(WM_NOTIFYICON, OnTrayNot)

    the messages start getting captured.

  10. #10
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: System Tray Application

    Have a look at the attached files. I wrote this class a few months back.

    And the Mouse button capturing code is in the .h file, commented part.
    Attached Files Attached Files
    ◄◄ hypheni ►►

  11. #11
    Join Date
    May 2011
    Posts
    2

    Re: System Tray Application

    Search with

    Shellnotifyiconex,c++ function

Tags for this Thread

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