Icon for exe

This is a discussion on Icon for exe within the Windows Programming forums, part of the Platform Specific Boards category; I know I can import icons into my Visual C++ project, but how do I define the icon to be ...

  1. #1
    Registered User Ward's Avatar
    Join Date
    Sep 2001
    Location
    Belgium
    Posts
    39

    Question Icon for exe

    I know I can import icons into my Visual C++ project, but how do I define the icon to be represented with the exe-file.
    My program is just a WIN32 application without MFC.

    Thanks in advance

  2. #2
    Registered User Esss's Avatar
    Join Date
    Aug 2001
    Posts
    133
    The application icon is the first icon in the resources.
    Ess
    Like a rat in a maze who says,
    "Watch me choose my own direction"
    Are you under the illusion
    The path is winding your way?
    - Rush

  3. #3
    Registered User Ward's Avatar
    Join Date
    Sep 2001
    Location
    Belgium
    Posts
    39
    Thanks, but I knew that already.
    What I was looking for is if it is possible to define the exe-icon from the list of icons in the resource?
    For instance: I have 3 icons in the list and I want to define icon 2 as the exe-icon.

  4. #4
    Banned maes's Avatar
    Join Date
    Aug 2001
    Posts
    744
    Is this what you are looking for

    when you register your window class:
    wndclass.hIcon= LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON2));

    this will load the icon for the exe file

    BTW:tof om hier nog nen Belg tegen te komen.

  5. #5
    Registered User Ward's Avatar
    Join Date
    Sep 2001
    Location
    Belgium
    Posts
    39
    Could that work?
    You've written some code that is executed when the exe is running.
    Logically the exe is build before you run it. So the visible exe-icon can't logically be defined in the code.
    I'm looking for is some sort of projectsetting to define the visible exe-icon.

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    72
    Hi
    You can play with the ID's of the icons.
    The one with the smallest ID will be used as icon for the EXE

    don't forget to rebuild all the project when you change the ID's in your 'resource.h' file.

    example:

    #define IDR_MAINFRAME 128
    #define IDI_ICON1 129
    #define IDI_ICON2 130

    will assign the first as 'icon for the exe'

    #define IDI_ICON1 1

    will assign that icon for the EXE

    damyan

  7. #7
    Registered User Ward's Avatar
    Join Date
    Sep 2001
    Location
    Belgium
    Posts
    39
    Thanks!
    That was exactly what I was looking for!


  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    >>when you register your window class:
    >>wndclass.hIcon=LoadIcon(NULL,MAKEINTRESOURCE(IDI _ICON2));

    This works for me. The exe has this icon instead of the standard windows .exe or .com icon. (I only have one icon so....)

    To set an icon for a window or dialog box (displayed in next to the title).

    SetClassLong(hWnd,GCL_HICON,(LONG) LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1)));

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Icon Help
    By The Brain in forum Windows Programming
    Replies: 11
    Last Post: 04-05-2009, 05:06 PM
  2. Problem with taskbar icon
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 05-16-2006, 02:55 AM
  3. Icon problem
    By mkyong in forum Windows Programming
    Replies: 0
    Last Post: 02-17-2003, 05:39 PM
  4. Icon? help!
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-16-2001, 06:21 PM
  5. icon in title bar?
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 12-12-2001, 06:43 PM

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