-
March 18th, 2009, 03:17 PM
#1
How do I give my program an icon?
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.
-
March 18th, 2009, 03:54 PM
#2
Re: How do I give my program an icon?
What kind of program do you have? Runs on Windows, Linux? Is it console, is it window app?
-
March 18th, 2009, 04:18 PM
#3
Re: How do I give my program an icon?
i also have this question. Im running xcode on a mac, writing a standard c++ program.
-
March 19th, 2009, 07:04 AM
#4
Re: How do I give my program an icon?
My program is a console application based on C++. It's for Windows.
-
March 19th, 2009, 08:05 AM
#5
Re: How do I give my program an icon?
Add (insert) an icon as a resource to your project.
Victor Nijegorodov
-
March 19th, 2009, 09:02 AM
#6
Re: How do I give my program an icon?
... 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.
-
March 20th, 2009, 04:24 AM
#7
Re: How do I give my program an icon?
You should also refer to your compiler. For example in Dev-C++ you could add an icon via Project options.
-
March 21st, 2009, 12:22 AM
#8
Re: How do I give my program an icon?
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.
-
March 21st, 2009, 06:24 AM
#9
Re: How do I give my program an icon?
Here:
Save this as .rc file
You can compile this using windres
Code:
windres -i resource.rc -o resource.o
Then compile it with your main .cpp file
Code:
g++ resource.o main.cpp -o main
If you are using an IDE, just include your .rc file in your project.
-
March 21st, 2009, 10:25 AM
#10
Re: How do I give my program an icon?
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:
Code:
C:/Plugins/srcds/icon windres -i resource.rc -o resource.o
Unknown command "windres"
Last edited by realchamp; March 21st, 2009 at 12:57 PM.
-
March 21st, 2009, 01:05 PM
#11
Re: How do I give my program an icon?
Okay, I tryed to include it (#include <resource.rc>)
I get this error:
Code:
syntax error "constant"
-
March 21st, 2009, 01:43 PM
#12
Re: How do I give my program an icon?
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
Code:
IDI_MY_ICON DISCARDABLE "icon.ico"
and make sure to define IDI_MY_ICON somewhere in your program.
hope this helps~
Last edited by potatoCode; March 21st, 2009 at 01:50 PM.
-
March 21st, 2009, 01:57 PM
#13
Re: How do I give my program an icon?
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.
-
March 21st, 2009, 02:13 PM
#14
Re: How do I give my program an icon?
Okay I got the
Code:
#define IDI_MY_ICON
In my program, just after the headers.
Now what do I do with?:
Code:
DI_MY_ICON DISCARDABLE "icon.ico"
Do I simply just put that in my source code somewhere after int main() { ?
EDIT: I did that, new errors:
Code:
DISCARDABLE : not a command.... blablabla...
Last edited by realchamp; March 21st, 2009 at 02:18 PM.
-
March 21st, 2009, 02:29 PM
#15
Re: How do I give my program an icon?
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 project
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)
Last edited by potatoCode; March 21st, 2009 at 02:44 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|