Executable Icon

BlitzMax Forums/BlitzMax Programming/Executable Icon

Tylerbot(Posted 2007) [#1]
How do I compile my project (on Windows) so that the output executable has an embedded icon?


tonyg(Posted 2007) [#2]
Does this not work still?


Yan(Posted 2007) [#3]
A simple front end for windres...

[EDIT]
...Can be found by clicking the link below...
[/EDIT]



Russell(Posted 2007) [#4]
Yan, the link is broke :(

Russell


Yan(Posted 2007) [#5]
Oops... :o/

Fixed now.


Tylerbot(Posted 2007) [#6]
tonyg - I followed the tutorial precisely, and my executable *does* contain an icon. However, it is only displayed in the windows explorer interface, not in the application's upper left corner when running. I compiled a *.ico file using snidesoft's tool, containing a 32x32 bitmap and a 16x16 bitmap, and correctly compiled it using a *.rc file using windres.exe. I'm stumped.


Yan(Posted 2007) [#7]
I'm stumped.
...And blind, it seems. ;op


Grey Alien(Posted 2007) [#8]
Tony's link points to an old-style method of setting the icon which isn't perfect (well actually let me be more precise, Jim Brown's method works to get the icon in some places but not the title bar, the old-style SetClassLong method to set the title bar icon doesn't work in XP with the standard theme but does work with Windows Classic theme - figure that one out!)

After lots of painful research I added the following code to my BlitzMax Game Framework which always works. You still need to have an exe icon like you are already doing with Jim Brown's tutorial:

' -----------------------------------------------------------------------------
' ccSetIcon
' -----------------------------------------------------------------------------
Function ccSetIcon(iconname$, TheWindow%)	
	?Win32
	Local icon=ExtractIconA(TheWindow,iconname,0)
	Local WM_SETICON = $80
	Local ICON_SMALL = 0
	Local ICON_BIG = 1
'	sendmessage(TheWindow, WM_SETICON, ICON_SMALL, icon) 'don't need this
	sendmessage(TheWindow, WM_SETICON, ICON_BIG, icon)
'	SetClassLongA(TheWindow,-14,icon)'obsolete as it doesn't work with Windows XP Theme!
	?
End Function

'call it like this
ccSetIcon(AppFile, GetActiveWindow())


and the externs:


?win32
Extern "win32"
	Function ExtractIconA%(hWnd%,File$z,Index%)
	Function GetActiveWindow%()
	Function SendMessage:Int(hWnd:Int,MSG:Int,wParam:Int,lParam:Int) = "SendMessageA@16"
End Extern
?



tonyg(Posted 2007) [#9]
Tony's link points to an old-style method

and also contains a link to your Code Archive entry which seems to have been missed or not read.


Grey Alien(Posted 2007) [#10]
yeah there is a link in there to a post of mine, but it's an old-style method too. here is the latest code archive entry (the update from Yan probably doesn't work on BMax 1.24 due to the call to PrimaryDevice):

http://www.blitzbasic.com/codearcs/codearcs.php?code=1841


Yan(Posted 2007) [#11]
Course it does! ;o)

As does the version included in the MakeObject.zip linked above (probably should have mentioned that in the original post). :o)


tonyg(Posted 2007) [#12]
... and all would have led to an icon in the top-left.
.
Yan's MakeObject works nicely and unless I am missing something (or it's been edited) there isn't a reference to primarydevice in that code archive.
Never mind I am sure Tylerbot now has an icon in the top left.


Grey Alien(Posted 2007) [#13]
Yan's ;-) says it all. EDITOR! ;-)


Tylerbot(Posted 2007) [#14]
I'll probably be flamed hardcore for saying this, but - shouldn't the ability to assign an icon to an executable be part of the compilation process (as with dev-cpp)?


Tylerbot(Posted 2007) [#15]
Oh and btw Yan - thanks for the MakeObject code, it works fine. I didn't notice you had fixed the link.


tonyg(Posted 2007) [#16]
shouldn't the ability to assign an icon to an executable be part of the compilation process
Many would agree.


Grey Alien(Posted 2007) [#17]
yup in agreement here.