Getting a .exe icon On Window, NO EXTERNAL FILES!

BlitzMax Forums/BlitzMax Tutorials/Getting a .exe icon On Window, NO EXTERNAL FILES!

Hey, maybe a bit late for responce, but...

Importing the object file embedds the icon into the compiled exe file... to place it on the window, you do step 5.. a function that calls out that embedded icon and places on the window.

Mind you, you need some windows external functions...

external win32 functions:

'Needed 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
?


function that calls out the exe icon and places it on the window.

' -----------------------------------------------------------------------------
' SetIcon
' -----------------------------------------------------------------------------
Function SetIcon(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_BIG, icon)
	?
End Function

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