Adding icon to your BlitzMax Application


Tweet blitzmax blitzmax-ng tutorials
(Posted 5 months ago) RonTek

A small tutorial will show you how to get a .exe icon for your exe file and on the window WITHOUT using external files with the finished product.

Authors: YahFree, caitsith2

  1. Create a winres resource script with the name of your icon file ex. app.ico

resfile.rc

101 ICON "app.ico"
  1. under command prompt, execute windres.exe (Visual Studio/MinGW binaries), this will produce icon_import.o
windres -i resfile.rc -o icon_import.o
  1. Add this to you code:
'Needed externs
?win32
Extern "win32"
    Function ExtractIconA%(hWnd%,File$z,Index%)
    Function GetActiveWindow%()
    Function SendMessage:Int(hWnd:Int,MSG:Int,wParam:Int,lParam:Int) = "[email protected]"
End Extern
?

' -----------------------------------------------------------------------------
' SetIcon
' -----------------------------------------------------------------------------
Function SetIcon(iconname$, TheWindow%) 
    ?Win32
    Local icon:Int=ExtractIconA(TheWindow,iconname,0)
    Local WM_SETICON:Int = $80
    Local ICON_SMALL:Int = 0
    Local ICON_BIG:Int = 1
    sendmessage(TheWindow, WM_SETICON, ICON_BIG, icon)
    ?
End Function

'call it like this
?Win32
SetIcon(AppFile, GetActiveWindow())
?
  1. Add the following lines on top of your main code. Note to add the SetIcon command created above after the Graphics command in your code.
Import "icon_import.o"

GLGraphics 800,600

SetIcon(AppFile, GetActiveWindow())
(Posted 5 months ago) hardcoal commented:

Thanks :) Ill Try it

Reply To Topic (minimum 10 characters)

Please log in to reply