Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi at all,

I’ve two questions to icons in a Visual Studio 2012 Win-Forms C++/CLI project:

1.) I’ve created “MyIcon.ico” and added it to app’s resource files:

App.rc:
IDI_MAIN ICON " MyIcon.ico"

resource.h:
#define IDI_MAIN 1

But my application shows the VS standard icon instead of mine.

2.) I’ve a form with a ToolStrip and a ToolStripButton and I’ve assigned an icon (Save.bmp) to my button. But isn’t there a possibility to assign predefined Windows standard icons to my controls?
In the app’s resource file there are shown lots of predefined (but not used) read-only symbols, e.g. ID_FILE_SAVE. But how to assign this ID (icon) to my button?

Thanx
Volker
Posted

1. Assuming the .rc is compiled and the .res linked, it could be the old problem of Windows caching icons, and not displaying the right icon when updating/linking a target. Two ideas to test that hypothesis; 1. select Properties on the exe in Explorer. That could extract the correct icon from it. 2. Copy the exe to a new name and see if that also fails to display the icon.

2. Have a look at the documentation for LoadIcon (maybe also LoadImage). You can indeed get a HICON for the system-provided icons frmo at least the former.
 
Share this answer
 
Comments
volker.de 2-Mar-15 5:21am    
Hi Mike,

thank you for helping. Sorry for my late answer, but I had my focus on other stuff.

1. You're right. It is a Win caching problem: when I change the name of my exe or select my icon in the properties, I see the right icon.

2. I can assign a explicit image file at develpoment time or at runtime with Image::FromFile( "c:\\save.bmp" ); (not LoadIcon or LoadImage) to my button. But I've not found any possibility to assign a windows predefined ID, like LoadIcon(ID_FILE_SAVE).
1. Check that the icon file is in the current directory, and is also the first ICON entry in the resource script.

2. You may use any of the predefined resource values in your scripts, as long as you use the same names in your main code. You should also ensure that any of your own definitions do not use the same values as the predefined names.
 
Share this answer
 
v2
Comments
volker.de 2-Mar-15 5:29am    
Hi Richard,

thank you for helping. Sorry for my late answer, but I had my focus on other stuff.

1. It was a Win caching problem: when I change the name of my exe or select my icon in the properties, I see the right icon.

2. > You may use any of the predefined resource values ...
Yes? But the question is: how? What's the name of the method?
But I've not found any possibility to assign a windows predefined ID, like LoadIcon(ID_FILE_SAVE).
I only found the possibility to assign a explicit image file at develpoment time or at runtime with Image::FromFile( "c:\\save.bmp" ).
Richard MacCutchan 2-Mar-15 5:42am    
2. You can use one of the predefined values in your resource script as the ID of your icon, but you will still need to provide the icon file itself; unless you are using one of the values listed in https://msdn.microsoft.com/en-us/library/windows/desktop/ms648072%28v=vs.85%29.aspx.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900