System Tray

This is a discussion on System Tray within the Windows Programming forums, part of the Platform Specific Boards category; Hi all, I need a sample win32api code for putting a icon in the system tray. And one more, sample ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Location
    Sarajevo, Bosnia and Herzegovina
    Posts
    18

    System Tray

    Hi all, I need a sample win32api code for putting a icon in the system tray.
    And one more, sample code for startup application with system, i know this going via registry, but don't know exactly.

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,904
    This should help.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    Jun 2005
    Location
    Sarajevo, Bosnia and Herzegovina
    Posts
    18
    Thanks man, this is what needed ;-)
    Just left a start of my application with system startup, sample code too, it is best way.

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    137
    Quote Originally Posted by jverkoey
    This should help.
    That's terrible code...
    Not only did i spend 15 minutes getting header files, and placing them in my folders. Only to find out the header files themselves don't work either, just errors everywhere. I've included everything, and no libraries were mentioned to link to.

    Please post code and then explain what they do.... what to link.... and what libraries are needed. This code requires specstring.h, safestr.h, and safestr.h just gives error after error.

    I'm either missing a library or this was coded by someone who wasn't thinking about ming compiler.

  5. #5
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,904
    Quote Originally Posted by execute
    That's terrible code...
    Not only did i spend 15 minutes getting header files, and placing them in my folders. Only to find out the header files themselves don't work either, just errors everywhere. I've included everything, and no libraries were mentioned to link to.

    Please post code and then explain what they do.... what to link.... and what libraries are needed. This code requires specstring.h, safestr.h, and safestr.h just gives error after error.

    I'm either missing a library or this was coded by someone who wasn't thinking about ming compiler.
    You're right, I wasn't thinking about the ming compiler. I use a real windows compiler for making windows-specific apps.

    Also, if you want the source of this information, I shelled the code from a C++ class here: http://www.codeproject.com/shell/system_tray.asp
    So enjoy using that code if you like.

    Code:
    // Required for balloon text information.
    #define _WIN32_IE 0x0600
    
    #include <windows.h>
    #include <string.h>
    #include <stdio.h>
    #include <commctrl.h>
    #include <shellapi.h>
    #include <richedit.h>
    #include <wininet.h>
    #include <time.h>
    #include "resource.h"
    
    
    // Taskbar Icon include.  This is located in a library directory
    //  of code.  Feel free to move TaskBarIcons.h/.cpp to this
    //  folder and change the relative path to include it easier.
    #include <TaskBarIcons.h>
    #include <strsafe.h>
    #include <shellapi.h>
    
    
    
    
    //////////////////////////////////////////////////////////////////
    ///////////////////////// LIBRARIES //////////////////////////////
    //////////////////////////////////////////////////////////////////
    
    #pragma comment(lib, "comctl32.lib")
    #pragma comment(lib, "shell32.lib")
    #pragma comment(lib, "winInet.lib")
    #pragma comment(lib, "comctl32.lib")
    
    
    
    //////////////////////////////////////////////////////////////////
    //////////////////////// DEFINITIONS /////////////////////////////
    //////////////////////////////////////////////////////////////////
    
    #define ICONID			0
    Last edited by jverkoey; 05-07-2006 at 07:06 PM.

  6. #6
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Thanks jverkoey I was actually messing around with tray icons too, this helped out a bit.
    My Website
    010000110010101100101011
    Add Color To Your Code!

  7. #7
    Registered User
    Join Date
    Jun 2005
    Location
    Sarajevo, Bosnia and Herzegovina
    Posts
    18
    Ok First code was allright, I because he cotainded a basic example functions of creating system tray icons, I just needed that, some to pushme from starting point of that problem.
    But I steel don't have a startup code .

  8. #8
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544

  9. #9
    Registered User
    Join Date
    Jun 2005
    Location
    Sarajevo, Bosnia and Herzegovina
    Posts
    18
    Quote Originally Posted by anonytmouse
    Ok, but registry is much better solution.
    I have one problem with system tray icon, I can't use a szInfo in NOTIFYICONDATA struct, when I use that I got error ('szInfo' is not a member of 'NOTIFYICONDATA'.
    So this problem is only with szInfo and szInfoTitle, but with others members I haven't a problem.
    I using MSVS 2003.NET

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. Replies: 3
    Last Post: 06-13-2005, 08:28 AM
  3. Why Can't C++ Be Used to Develop Operating System?
    By Antigloss in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2005, 07:16 AM
  4. System Tray = Notification Area
    By JasonD in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 09-12-2003, 01:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21