-
June 28th, 2012, 02:14 PM
#1
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
-
June 28th, 2012, 02:43 PM
#2
Re: Missing Icons in MFC application if additional window is used at startup.
Originally Posted by bpostiff
... some icons will not show up in the rest of the application.
Please, define:
- the rest of the application
- "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
-
June 28th, 2012, 02:58 PM
#3
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.
-
June 28th, 2012, 03:02 PM
#4
Re: Missing Icons in MFC application if additional window is used at startup.
Originally Posted by bpostiff
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?
-
June 28th, 2012, 03:10 PM
#5
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"
-
June 28th, 2012, 03:14 PM
#6
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
-
June 28th, 2012, 03:29 PM
#7
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
-
June 28th, 2012, 03:37 PM
#8
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.
-
June 29th, 2012, 03:07 AM
#9
Re: Missing Icons in MFC application if additional window is used at startup.
Where do you call all these LoadIcon/Add from?
Victor Nijegorodov
-
June 29th, 2012, 09:30 AM
#10
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.
-
June 29th, 2012, 09:47 AM
#11
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|