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

    Missing Icons in MFC application if additional window is used at startup.

    Hello,

    I am currently working on an MFC application which can be launched two different ways.

    1. No command line arguments. The application launches and shows a dialog which lets the user select which sub-appliation to run.

    2. Launched with command line argument that directs the application on which sub-app to use. No extra dialog shown to the user.

    The problem I am having is this.

    If the application is launched with a command line argument that states which sub application to use, everything is fine. All the icons specified in my application resources display correctly throughout the application. If however, the application is launched without command line argument to specify the sub-app, and the extra dialog is displayed to allow the user to choose mode, some icons will not show up in the rest of the application. The problem only happens in Windows XP though. Windows Vista and 7 everything is ok. Something related to the extra dialog during initialization is causing the icon resouces to not load. I was hoping someone would have an idea. I have not posted any code as I am more in search of some conceptual ideas rather than specific code. Any ideas?

    Thanks

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Missing Icons in MFC application if additional window is used at startup.

    Quote Originally Posted by bpostiff View Post
    ... some icons will not show up in the rest of the application.
    Please, define:
    1. the rest of the application
    2. "some icons will not show up" - which icons "not show up" and how they differ from all the others that "show up" as expected.
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2012
    Posts
    6

    Re: Missing Icons in MFC application if additional window is used at startup.

    Sorry for not giving clear enough info.

    Actually, it is not some of the icons, it is all of them. And I mis-spoke when I said rest of the application. I should have just said, that the icons don't show up in the application at all. Only in XP though.

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Missing Icons in MFC application if additional window is used at startup.

    Quote Originally Posted by bpostiff View Post
    Sorry for not giving clear enough info.

    Actually, it is not some of the icons, it is all of them. And I mis-spoke when I said rest of the application. I should have just said, that the icons don't show up in the application at all. Only in XP though.
    Which icons, where, how are you using them?

  5. #5
    Join Date
    Jun 2012
    Posts
    6

    Re: Missing Icons in MFC application if additional window is used at startup.

    The icons are used in various dialogs throughout the application. In one situation I attempt to add the icons to an image list like the following and then have them show up as the icon for list view items.

    m_smallImageList.Create(16, 16, FALSE, 1, 0);
    HICON hIcon = ::LoadIcon(AfxGetResourceHandle(),
    MAKEINTRESOURCE(IDI_UNLOCKED));
    m_smallImageList.Add(hIcon);
    hIcon = ::LoadIcon(AfxGetResourceHandle(),
    MAKEINTRESOURCE(IDI_LOCKED));
    m_smallImageList.Add(hIcon);
    hIcon = ::LoadIcon(AfxGetResourceHandle(),
    MAKEINTRESOURCE(IDI_SHARED));
    m_smallImageList.Add(hIcon);

    m_cbList.SetImageList(&m_smallImageList, LVSIL_SMALL);

    m_cbList.SetExtendedStyle(LVS_EX_FULLROWSELECT);

    The icons are defined in .rc file as such:

    /////////////////////////////////////////////////////////////////////////////
    //
    // Icon
    //

    // Icon with lowest ID value placed first to ensure application icon
    // remains consistent on all systems.
    IDI_UNLOAD ICON DISCARDABLE "res\\unloaded.ico"
    IDI_LOCKED ICON DISCARDABLE "res\\locked.ico"
    IDI_UNDISPLAYABLE ICON DISCARDABLE "res\\undisplable.ico"
    IDI_UNLOCKED ICON DISCARDABLE "res\\unlocked.ico"
    IDI_CHECKED ICON DISCARDABLE "res\\checked.ico"
    IDI_UNCHECKED ICON DISCARDABLE "res\\unchecked.ico"
    IDI_SHARED ICON DISCARDABLE "res\\icon1.ico"
    IDI_PATHCOLLISION ICON DISCARDABLE "res\\pathcollision.ico"
    IDI_PATHOUTLIMITS ICON DISCARDABLE "res\\pathoutlimits.ico"

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Missing Icons in MFC application if additional window is used at startup.

    Well,
    do all these 16x16 icons really exist in the resources?
    what do al these calls of ::LoadIcon and m_smallImageList.Add(hIcon) return?
    Victor Nijegorodov

  7. #7
    Join Date
    Jun 2012
    Posts
    6

    Re: Missing Icons in MFC application if additional window is used at startup.

    Yes, they all exist as 16x16, 16 color icons.

    The value of hIcon after a call to LoadIcon :

    0x2a920d51 {unused=000 }

    A call to "m_smallImageList.Add(hIcon)" returns 2

  8. #8
    Join Date
    Jun 2012
    Posts
    6

    Re: Missing Icons in MFC application if additional window is used at startup.

    I should say a call to "m_smallImageList.Add(hIcon)" does NOT return -1 which would indicate failure.

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Missing Icons in MFC application if additional window is used at startup.

    Where do you call all these LoadIcon/Add from?
    Victor Nijegorodov

  10. #10
    Join Date
    Jun 2012
    Posts
    6

    Re: Missing Icons in MFC application if additional window is used at startup.

    The load/add calls are made from the OnInitDialog() method of various dialog boxes used in the application. I also found out another piece of interesting information.
    When this extra dialog is used during application initialization, some of our international customers have complained of text input areas in the software being reversed. That is character entry starts at the right and goes left. Only on Windows XP though. Somehow it seems that it is not just an icon problem, but maybe a more widespread resource issue that occurs only when this extra dialog is displayed during app initialization.

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Missing Icons in MFC application if additional window is used at startup.

    Could you provide more info about your App?
    Or, better, create a very small test project reproducing such a strange behavior (and only on XP!) and post it to the Forum so we could test it and try to understand the problem?
    Victor Nijegorodov

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