开发者

Adding new icon into the resource-Visual studio

I have an icon named XX.ico.

I want to add it in the project x. How do i achieve it. If i right click on the project resource, it gives me option add icon,when i do so,one new icon is added which is allowing me to edit the image. But i want开发者_如何学C to place my XX.ico in that resource.how do i do it ?please help...


right click the project then select properties. Select the resources tab and select the downward arrow next to "Add Resource" and select add existing file. Then navigate to XX.ico and select the file.


add this in your script .rc file

MYICON1 ICON "testicon.ico"

MYICON1 is identifier and icon is type make sure you replace the file name

now in resource.h file add this

#define MYICON1  101

and now call it when prog starts

HICON Icon = LoadIcon(hInstance, MAKEINTRESOURCE(MYICON1));

have a good day.....


This can be achieved easily. Just right click on your project-> add-> resource. Add resource window would have popped up where in you can select icon as your preference and select import. Then it lets you to browse through your directory and select your icon. Along with the image edit option, you can find the icon added to the resource file of the project. This is in VS 2013. I think its similar in VS 2010 too.


it can be achieved easily with LoadImageW :

HICON MYICON = (HICON)LoadImageW(NULL,L"myicon.ico",IMAGE_ICON,32,32,LR_LOADROMFILE);


As mentioned in the comment, by Thomasz, this can be done with the .resx file. However, this doesn't help if your .resx file doesn't exist or you don't even know what a .resx file is.

In VS2022, go to project-properties. Select the Resources section, and then use the "Create or open assembly resources". At the top of the window select the arrow next to "Add Resource" and then select "Add Existing File...".

Once selected, the icon is added to the resource file (and created, if necessary). The icon can be selected with the project properties Icon-Browse, and the project can then be published without any errors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜