Dark Bit Factory & Gravity

PROGRAMMING => Coding tutorials => Topic started by: Clyde on July 06, 2009

Title: Adding An Icon To Your Executables!
Post by: Clyde on July 06, 2009
Introduction:
As the topic implies this little thang will allow you to add an identity to your FreeBASIC proggies.


What You'll Need:
An icon image file .ico - A few are supplied to Transform your .exe's, see zip attachment.
A text editor Note Pad is just grand.
Optional: A paint package that allows the ability to churn out .ico files or better still an icon editor.


Before We Start:
By adding an icon it will increase your overall program file size.

I've supplied a zip archive of some icons for you to have a play with, there are a lot of freebies available if you search the web for them.

Also use icons in the size of 32 by 32. I've tried with bigger sizes but they get resized when the object file is created and your program is compiled.


Lettuce Begin:
First of all save / copy and paste your icon into the program you wish to add the particular icon to, if you want to add it to your media / graphics folder than just remember to put the directory path into the icon file location.

Now open up Notepad or your prefered weapon of choice in the text editor department and type in the following:

Code: [Select]
fb_program_icon icon "name_of_icon.ico"

Nows time to navigate to save, and select to save it as all types of files in the drop down menu, important this part, otherwize you'll be creating a text document rather than the actual type of file we need.

And call it a suitable name, for example add_icon followed by a dot rc and make sure you save it into your main programs root directory.


And Finally!
In FBIDE -> View -> Settings -> FreeBASIC

Under Compiler Command in the tab along side your usual compiler settings, at the end enter in quotes "add_icon.rc" ( By the way same similar scenario with compiling on the command prompt )

And now OK it, when you next compile with F9 ( not F5 ) your program executable should now have a neat piccie applied!!


Extra Extra!:
Ico FX (http://icofx.ro/) - free icon utility and really awesome allows you to import your own images and apply settings to convert into icons. Thanks to Xone for posting the link in another thread.

Known Issues
If you are using fbgfx lib then you will see a smaller icon on your windows title bar when not in full screen mode. However in TinyPTC / TinyPTC_Ext you will just have an icon applied to your exe.

Cheers and Happy Coding,
Clyde.
Title: Re: Adding An Icon To Your Executables!
Post by: DrewPee on September 09, 2009
Nice one Clyde - didn't know you could do that! ;)   :goodpost:
Title: Re: Adding An Icon To Your Executables!
Post by: Clyde on September 23, 2009
Thanks Man and now you do!! ;)
Title: Re: Adding An Icon To Your Executables!
Post by: bobfresh on March 03, 2010
Quick side note/question.

If I try adding an XP+ manifest to the executables resource section, it generates a program error!!
added: the error is in the generated exe not in GoRC or FBC. also the same problem is not repeatable in my other language -masm32.

Conveniently i found a picture that depicts the effect on the exe alot better than i could describe it...

it looks a bit like this....  :boxer:   

Does anyone have a fix for this that doesn't involve adding a myprog.exe.manifest to the directory?

thx in advance - bob
Title: Re: Adding An Icon To Your Executables!
Post by: Rbz on March 03, 2010
I'm not sure but maybe you're using a wrong manifest file?

Check this out, I used some examples found here  (http://www.freebasic.net/forum/viewtopic.php?t=5974&highlight=manifest)and here (http://www.freebasic.net/forum/viewtopic.php?t=7781&highlight=manifest).



Title: Re: Adding An Icon To Your Executables!
Post by: Clyde on March 03, 2010
I see, a password system.
Title: Re: Adding An Icon To Your Executables!
Post by: bobfresh on March 12, 2010
rzb yup that fixed it alright.

I was using an old hacked up XP manifest that ive been using for years on masm32 w/ no issues. Strange that it only kicked off when embedded in the RSRC section though... meh.  I only need windows to 'skin' the std controls like buttons and listboxes .etc. so that example is perfect.

          Thanks for that.