Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add custom icon to .exe visual C++ 1

Status
Not open for further replies.

danstancu

Programmer
May 28, 2007
2
RO
Hi, I am new to Visual C++.
Is it possible to add a custom icon to an win32 application (foo.exe)?

Thanks
 
I'll assume you're using Visual C++ 6.0. The others are similar. Start from a new project.

1) Create a new project
2) Make it a Windows Application
3) Select a Hello World Application
4) Have a look at the only .cpp file other than stdafx.cpp.
5) Look for the routine called MyRegisterClass
6) The two statements you're interested in are
Code:
wcex.hIcon	= LoadIcon(hInstance, (LPCTSTR)IDI_WHATEVER);
wcex.hIconSm	= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
All windows programs have 2 icons: a 32x32 and a 16x16. The 32x32 appears in explorer and the 16x16 appears on the taskbar when the program is running. Visual studio has a 16 colour icon editor.

I don't know how you're writing your coding. Some use the wizards. Personally, I hate the Malaysian variable stuff (everything beginning with My) and the neither here nor there camel/Hungarian notation so I have my own templates. I could go on forever about how much I dislike Hungarian notation but you're probably not interested so I'll just shut up.
 
Forgot to add - you'll find the IDI definitions in the resources (.rc file). If you're using Visual Studio, it will be in the icon subtree.
 
Thanks a lot xwb!
I will try it ASAP and notify you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top