Hello, all!
How do I give my program an icon?
I don't want a .jpg picture in my program folder. How do I code it into the program?
Cheers,
realchamp.
Printable View
Hello, all!
How do I give my program an icon?
I don't want a .jpg picture in my program folder. How do I code it into the program?
Cheers,
realchamp.
What kind of program do you have? Runs on Windows, Linux? Is it console, is it window app?
i also have this question. Im running xcode on a mac, writing a standard c++ program.
My program is a console application based on C++. It's for Windows.
Add (insert) an icon as a resource to your project.
... or after building the executable, you can use a program like exescope:
http://hp.vector.co.jp/authors/VA003525/emysoft.htm#6
There are a lot of these... if especially this one is licensed or doesn't work for you.
You should also refer to your compiler. For example in Dev-C++ you could add an icon via Project options.
I've trying alot to get it work. I can by now add it as a ressource.
However, to get it work. What code do I need to use? I've using google for 3 hours now. It seems to make no sence now. I hope you can help me!
Thanks,
- realchamp.
Here:
Save this as .rc fileCode:1 ICON "icon.ico"
You can compile this using windres
Then compile it with your main .cpp fileCode:windres -i resource.rc -o resource.o
If you are using an IDE, just include your .rc file in your project.Code:g++ resource.o main.cpp -o main
Ahh I got that. Thank you, I will just try it.
EIDT: The IDE is that for a console application for Windows?
That resource.rc, how do I exactly create that? Or is that the file I "extra" included?
EDIT: The "windres" doesn't work.
I did:
Unknown command "windres"Code:C:/Plugins/srcds/icon windres -i resource.rc -o resource.o
Okay, I tryed to include it (#include <resource.rc>)
I get this error:
Code:syntax error "constant"
Hello realchamp
You don't need to include your resource file.
To mannually add the icon, (and probablly the easiest way)
just open up your favorite editor (or notepad) and save it with the .rc extension.
And do what richard_tominez showed you.
He put the constant for simplicity, (and used in only one place)
but you'd normally want to use macro
and make sure to define IDI_MY_ICON somewhere in your program.Code:IDI_MY_ICON DISCARDABLE "icon.ico"
hope this helps~
Okay, I will just try that. Thank you, PotatoCode :)
But where do I have to save my resource.rc?
Right now I have in the same folder as my main(.cpp) program is in.
Okay I got theIn my program, just after the headers.Code:#define IDI_MY_ICON
Now what do I do with?:Do I simply just put that in my source code somewhere after int main() { ?Code:DI_MY_ICON DISCARDABLE "icon.ico"
EDIT: I did that, new errors:
Code:DISCARDABLE : not a command.... blablabla...
Okay,
You forgot the ICON inbetween.
DISCARDABLE is optional and not required.
why don't you try this?
1. Open up a new console project.
2. Add/Create a blank file
3. In this new file type
4. Save this file as myresource.rc in the root directory of the projectCode:1 ICON "icon.ico"
5. Check your project manager to see the newly added myresource.rc
6. Build and run
7. check your exe to see if the icon has been added.
edit:
Just in case, you want to replace icon.ico with the actual file name of your icon.
To create your own icon,
you can download icon plug-ins for photoshop. (google it) :)