Creating an icon

BlitzPlus Forums/BlitzPlus Programming/Creating an icon

Grey Alien(Posted 2005) [#1]
I am using protean for BlitzPlus but it doesn't let you associate an icon with the .exe (it does for Blitz2D and 3D!). Can anyone recommend a program to do this easily?

Also I have used the free Imagicon program but it only seems to save a single size, surely so that my .exe has a decent icon in different display modes I need a 16x16, 32x32 and 48x48 icon or will windows scale it for me?

Thanks!


VIP3R(Posted 2005) [#2]
Windows will scale it for you, a 32x32 icon would probably be best.

I'm planning on adding multiple icon files to Imagicon at some point ;)

Here is some code for changing the B+ icon...

icon=ExtractIconA(QueryObject(window,1),"youricon.ico",0)
SetClassLongA(QueryObject(window,1),-14,icon)

And the decls...

.lib "user32.dll"
SetClassLongA%(hWnd%,nIndex%,Value%):"SetClassLongA"

.lib "shell32.dll"
ExtractIconA%(hWnd%,File$,Index%):"ExtractIconA"


Nicstt(Posted 2005) [#3]
And the decls...

.lib "user32.dll"
SetClassLongA%(hWnd%,nIndex%,Value%):"SetClassLongA"

.lib "shell32.dll"
ExtractIconA%(hWnd%,File$,Index%):"ExtractIconA"


ok please make it simple for someone like me, what do i actually enter into the 'dll's

thanks


Grey Alien(Posted 2005) [#4]
Thanks VIP3R, I'll give it a try!
[Edit] uh, yeah, seems I'm too dumb to get this to work. Anyway, when you say change the Blitz Plus icon, what do you mean? I want to change the .exe icon which is currently just a standard "no icon window" for an .exe. [/Edit]


VIP3R(Posted 2005) [#5]
Ok, I'll try and explain it a little better ;)

The code I mentioned above is for changing the icon within the B+ application title bar itself, not the exe.

To change the exe icon, I use ResHack which is a Win32 file utility. You can find it here

You need to have your icon prepared then do the following...

Open your exe in ResHack
Select 'Action' then 'Add a new resource'
Select your icon and fill in the empty fields with 'ICON'
Save the exe

To change the icon on the B+ application title bar...
Prepare your icon file and save it in the application folder.

Now make two text files using notepad...

.lib "user32.dll"
SetClassLongA%(hWnd%,nIndex%,Value%):"SetClassLongA"


Save the above text as 'user32.decls' and place it in your B+ userlibs folder.


.lib "shell32.dll"
ExtractIconA%(hWnd%,File$,Index%):"ExtractIconA"


Save the above text as 'shell32.decls' and place it in your B+ userlibs folder.

Now restart B+ and add this code to your B+ application source after creating your window...

icon=ExtractIconA(QueryObject(window,1),"youricon.ico",0)
SetClassLongA(QueryObject(window,1),-14,icon)

'window' is the name (handle) you used when creating the window...
i.e. window=CreateWindow(title$,x,y,width,height[,group[,style]])

'youricon.ico' is the name of your icon file.

Voila :)


Grey Alien(Posted 2005) [#6]
Truly excellent thanks VIP3R


VIP3R(Posted 2005) [#7]
You're welcome ;)


Grey Alien(Posted 2005) [#8]
Just added the icon to my mini game, check out the showcase for Tetroid.


Nicstt(Posted 2005) [#9]
awesome, thanks:)