icons

closed account (zwA4jE8b)
How do I make an icon a part of my project?

I am using VS 2010.

I know how to load and icon from a file but I would like it to be built into the exe.
closed account (1vRz3TCk)
How to: Create a Resource: http://msdn.microsoft.com/en-us/library/8fc1e5by.aspx
closed account (zwA4jE8b)
cool, now I have the icon resource added.
by default it created a file 'icon1.ico' so in my project folder i just deleted that file and replaced it with my icon that i had already created.

when setting up my window i tried this, and when my firewall asks me to allow the progrom my icon is used, but after that when the actual window is displayed the icon is not used. it is the default exe icon. what am i doing wrong?

wc.hIcon = LoadIcon(hInstance, "icon1.ico");
Last edited on
closed account (zwA4jE8b)
#include "resource.h"
wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));

got it, thank you CodeMonkey
closed account (1vRz3TCk)
you are welcome.
Note that (according to MSDN) "This function has been superseded by the LoadImage function." Though this doesn't stop a lot of people from still using LoadIcon.

LoadImage was introduced in Windows 2000, so that's how long LoadIcon has been deprecated!

Last edited on
Thanks, it helped me a lot.
Topic archived. No new replies allowed.