CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2002
    Posts
    74

    Application icon problem with multiple-document templates (MFC/MDI)

    Hi,

    I've created a MFC/MDI application with multiple document templates. When I run the application it's icon is the default MFC icon but the icon of the executable is the icon of one of the documents. I can't seem to figure out why and how this is the case. I want my executable to have to same icon (the one in IDR_MAINFRAME) as my application.

    Can someone shed some light this?

    Thanks...

  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917
    It is possible that you have created icon that has ID lower than IDR_MAINFRAME.

    Make sure that icon you want to show as your executable icon has the lowest ID.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    Sep 2002
    Posts
    115
    I know how to change the application image and that it must be the lowest ID, but what I don't know is how to via compiler options (defines etc) set what application icon to use.
    Why?
    Well I want to use different application icons for different builds.
    The same goes for version info. I know you can make blocks for different languages but my builds all uses the same language but I want the program name (and icon) that shows up in the Open With... list to be different depending on what build setting I've compiled (yes they all generate different exe files) and as that information is taken from the version info I need to alter it for each build.

    Anyone?

  4. #4
    Join Date
    Feb 2002
    Posts
    60
    Hi,
    Great to hear someone encountered the same problem.
    Here is the answer:
    #if defined _FIRST
    IDR_MAINFRAME ICON DISCARDABLE "res\\icon_1.ico"
    #elif defined _SECOND
    IDR_MAINFRAME ICON DISCARDABLE "res\\icon_2.ico"
    #endif

    Put it in .rc2 file since .rc file does not get #ifdef.

    The question is if we can do the same thing for the document icon? I've tried that and it works fine (e.g. when I call File->Open from inside the application I see the correct icon in the open dialog box) but the file manager always show the same one for both applications.
    Anyone? It is quite an emergency. I have release today!

  5. #5
    Join Date
    Sep 2002
    Posts
    115
    Originally posted by Haim B
    Hi,
    Great to hear someone encountered the same problem.
    Here is the answer:
    #if defined _FIRST
    IDR_MAINFRAME ICON DISCARDABLE "res\\icon_1.ico"
    #elif defined _SECOND
    IDR_MAINFRAME ICON DISCARDABLE "res\\icon_2.ico"
    #endif

    Put it in .rc2 file since .rc file does not get #ifdef.

    The question is if we can do the same thing for the document icon? I've tried that and it works fine (e.g. when I call File->Open from inside the application I see the correct icon in the open dialog box) but the file manager always show the same one for both applications.
    Anyone? It is quite an emergency. I have release today!
    I actually solved my problem long time ago using a different method. Interesting to see another solution though.
    My solution was to use conditions (property on a resource icon).
    I use my method for using different document icons too (and it works great!). You have to use different IDs though and add an #ifdef where your program uses that ID (initinstance when creating the doc template for instance).

    But when thinking about it, your method should work too, but you have to add another ifdef in the rc2 file for the document template ID of the document as well

    Hope this helped!
    Last edited by ackabacka; October 2nd, 2003 at 04:44 PM.

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