Thread: Popup taskbar icon

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    23
    [mod edit]This post refers to this thread:

    http://cboard.cprogramming.com/showthread.php?t=79130
    [/mod edit]

    Hi veecee

    I'm new to this board but have been visiting other C++ boards for a couple of months. I've gone through the "Hello World", for ... next and other loops etc. I'm interested in creating a custom System Tray icon and have seen code on The Code Project and Planet Source Code. I have Dev-C++ and VCEE but I prefer the former.

    I was very pleased when your code compiled correctly (with Dev-C++) and I'd like to add a custom icon. I realise that I'll have to include the icon details as the code is compiled but how exactly would I include it as a resource? I realise that I can add a resource file (tab) on the right side of the Dev-C++ editing screen but, if that's the right way to go about it, what do I write in the resource file? Is it the filepath and name of the icon or do I need to copy and paste binary/hex data (for instance)?

    I would have sent you a PM but it seems that I'm not allowed to do that yet!

    Finally, you said that you had a version which has a popup menu - I'd like to see that, if you don't mind posting it.

    Thanks for your time (and patience)!
    Last edited by Ken Fitlike; 06-10-2006 at 03:44 PM. Reason: split from bumped thread

  2. #2
    Registered User
    Join Date
    Jun 2006
    Posts
    23
    Apologies.

    The original thread was started on 15 May 2006 and the final response was on 16 May 2006. Like many newcomers, I didn't read the forum-specific guidelines, but I will now! I woudn't have resurrected a thread that was many months old but I thought that it would be OK to do so with one that was between three and four weeks old.

    As I mentioned, I would have PMd veecee directly but, when I clicked the name or <Members List>, it said that I didn't have permission to access that. I assumed that PMs weren't permitted until a certain number of posts had been reached.

    This "rap on the knuckles" hasn't dissuaded me - I just hope that veecee (or someone else) is able to help me!

  3. #3
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    You can load an icon from an .ICO file using LoadImage.

    Code:
    HICON LoadIconFromFile( LPCTSTR fileName ) {
      return (HICON)LoadImage( NULL, fileName, IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
    }
    You can also load an icon from an icon resource using LoadIcon.

    Code:
    LoadIcon( hInst, MAKEINTRESOURCE(INSTALL_ICON) );
    To set your system tray icon, assign your icon handle to the hIcon member of NOTIFYICONDATA.

    Code:
      NOTIFYICONDATA data ;
      data.hIcon = LoadIcon( hInst, MAKEINTRESOURCE(INSTALL_ICON) );
    To create an icon resource, add a ICON resource statement into a .RC file:

    Code:
    #include "iconresource.h"
    INSTALL_ICON ICON "install.ico"
    INSTALL_ICON is the identifier for the icon, which is defined in iconresource.h:

    Code:
    #define INSTALL_ICON 103
    Add the iconresource.h file into your project and compile it.

  4. #4
    Registered User
    Join Date
    Jun 2006
    Posts
    23
    That's great - I'll have a go. Just to clarify, I assume that the:

    <fileName> in ... ( NULL, fileName, IMAGE_ICON ...

    and

    <"install.ico"> in ... INSTALL_ICON ICON "install.ico" ...

    are the full filepath and name of the icon on my hard drive that I want to use?

  5. #5
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    It can be the relative path from the current working directory.

  6. #6
    Registered User
    Join Date
    Jun 2006
    Posts
    23
    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with taskbar icon
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 05-16-2006, 01:55 AM
  2. Problem with an icon in the TaskBar status area
    By dit6a9 in forum Windows Programming
    Replies: 2
    Last Post: 08-16-2004, 10:33 PM
  3. Replies: 2
    Last Post: 08-09-2003, 04:44 AM
  4. dialog taskbar icon
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 04-27-2002, 04:31 PM
  5. minimize all icon shortcut in taskbar, need replace...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-03-2002, 03:50 AM