=====>>> THIS IS FOR WINDOWS <<<=====
I asked how to do this, and a few people helped out and this is their Idea's/help mixed together in a working method.
this 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.
Step 1----------------------------------
make a folder: "IconMaker" i like to keep this near my project folders, so i can easely grab the produced .o file and drop it in the project folder.
Step 2----------------------------------
now get these 3 files in this "IconMaker" folder:
1: "icon.ico" ;your icon (32x32 .ico) this will be the icon on the exe file.
2: "resfile.rc" ; create this with notepad with the following line:
3: "windres.exe" ; from your MinGW/bin
Step 3-----------------------------------
Now, open notepad and add the following line:
save this as build.bat in the same "IconMaker" folder
Step 4-----------------------------------
Now simply double click the .bat file to produce your icon .o file.
this was hard to set up, but now making a new icon res file is as easy as dropping a new icon into that folder, and deleting the other one, then re double clicking the .bat file.
Step 5------------------------------------
Now to get it on the window call the following function right after Graphics.
you'll also need the following win32 externs:
(Credits to grey alien for that function, this will extract the icon out of your exe file and display it on the window.)
now the result is a completely independant compiled exe that needs no external files to display its icon.
heres an example:
I asked how to do this, and a few people helped out and this is their Idea's/help mixed together in a working method.
this 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.
Step 1----------------------------------
make a folder: "IconMaker" i like to keep this near my project folders, so i can easely grab the produced .o file and drop it in the project folder.
Step 2----------------------------------
now get these 3 files in this "IconMaker" folder:
1: "icon.ico" ;your icon (32x32 .ico) this will be the icon on the exe file.
2: "resfile.rc" ; create this with notepad with the following line:
101 ICON icon.ico
3: "windres.exe" ; from your MinGW/bin
Step 3-----------------------------------
Now, open notepad and add the following line:
windres -i resfile.rc -o icon_import.o
save this as build.bat in the same "IconMaker" folder
Step 4-----------------------------------
Now simply double click the .bat file to produce your icon .o file.
this was hard to set up, but now making a new icon res file is as easy as dropping a new icon into that folder, and deleting the other one, then re double clicking the .bat file.
Step 5------------------------------------
Now to get it on the window call the following function right after Graphics.
' ----------------------------------------------------------------------------- ' 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())
you'll also need the following win32 externs:
'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 ?
(Credits to grey alien for that function, this will extract the icon out of your exe file and display it on the window.)
now the result is a completely independant compiled exe that needs no external files to display its icon.
heres an example:
Import "icon_import.o" '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 ? Graphics 800,600 SetIcon(AppFile,GetActiveWindow()) While Not AppTerminate() = True Cls Flip Wend End 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