Author -Jim Brown (config2000 - hotmail - com)
This guide is intented to assist you in adding icons to your BlitzMax executables. The method used here avoids the need to continuously 'hack' the final executable (via Reshack for instance).
Instead, your source code will import an object file which contains the applications icon. The benefit being you can keep changing and re-compiling your source code and the icon will always appear.
For the purposes of this guide lets assume your application is called myapplication.bmx and resides in:
C:\BlitzMax\myproject\
Also, you should have an icon available. In this guide the icon is called myicon.ico and is also present in the C:\BlitzMax\myproject folder. See links below for icon editing.
For reference here are all the files which you will end up with in your folder:
| C:\BlitzMax\myproject\ | projects folder |
| myapplication.bmx | main source code |
| myicon.ico | icon file |
| resfile.rc | resource file (created at step 1 in this guide) |
| projecticon.o | object file (created at step 3 in this guide) |
MinGW installed for the WINDRES.EXE DOS
command. See links below.
If you do not have MinGW installed visit www.mingw.org
and obtain the installation file from there.
Here is Mark Siblys guide for setting up and installing MinGW
for BlitzMax module building:
NOTE: This stage is optional and can be
skipped
Since the resource file (resfile.rc) is a
simple text file you can use Notepad to create it.
The resource file will contain 3 entries on a single line
(separated by a SPACE):
| 101 | resource name |
| ICON | resource type |
| C:\BlitzMax\myproject\myicon.ico | resource location |
Enter the values into notepad like so:
101 ICON C:\BlitzMax\myproject\myicon.ico
Save the file with a *.rc extension in your
project folder.
For the purposes of this guide call it resfile.rc
Open a DOS window. If you have MinGW installed and your PATH environment variables set up correctly you can call the WINDRES command directly. Try this:
| > windres -? |
If you see a list of parameters proceed to step
3.
If you got a 'command not
recognised' error you'll need to change the
current folder into MinGW's bin folder and try again. Or, add
MinGW's bin location to your path. Example:
| > PATH=C:\mingw\bin;%PATH% |
The object file is the file which your BlitzMax code will import. This is created by using WINDRES and 2 parameters:
-i <inputfile> - The resfile.rc created in step 1
-o <outputfile> - An object file which your BlitzMax code will be importing
For the guide this is what you would enter in the DOS window:
| > windres -i C:\BlitzMax\myproject\resfile.rc -o C:\BlitzMax\myproject\projecticon.o |
A projecticon.o file should now be present in the C:\BlitzMax\myproject folder
Open up your BlitzMax source code (myapplication.bmx)
Enter the following at suitable point:
| ?Win32 Import "projecticon.o" ? |
Compile and run the source code. The icon should appear in
upper/left corner of the applications window.
Remember, you can re-compile as much as you like. The icon will
always be present!
www.irfanview.com - Image
viewer which can save the image as an icon.
www.snidesoft.com - snIco
Edit which is a free-to-use icon editor.
www.mingw.org - minGW installation
www.blitzmax.com , www.blitzbasic.com -
Official Blitz products site
www.codersworkshop.com
- Alternative support site
This guide has been put together thanks to the help of the BlitzMax community