.EXE icon...
BlitzMax Forums/BlitzMax Programming/.EXE icon...
| ||
New to blitzmax, in blitz3d you used some method to hack the EXE's resource file and implant the icon, now this method still holds true but i'v seen some methods that seem easyer, like importing an *.o file in the code and bam you have your icon.. anyone care to share? i'd like to have one on the physical exe file, one on the system tray below, and one of the window aswell. is this possible? |
| ||
Icon Guide If you search the Code Archives and forums with 'Icon' you will find a few posts with information like this |
| ||
thanks i'll give it a try.. |
| ||
hmm, the winres command works, but when i try to use it(correctly according to that page) it doesnt create the file. any ideas? basicly i get the same message as when i type "windres -?" |
| ||
I personally just use the Resource Hacker method for my final EXE and this for the window and task bar icons. |
| ||
create a batch file containing:%MINGWDIR%/bin/windres -i res.rc -o res.o then make a file called res.rc, then paste this: 101 ICON icon.ico you have to change the icon name to whatever your using. you can also add XP theme manifests by adding another line: 1 24 manifest.txt the text inside manifest.txt should be: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity name="XPManifest" processorArchitecture="x86" version="1.0.0.0" type="win32"/> <description>Windows Shell</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly> |
| ||
sorry, but whats a batch file and how do i make one? i got the resfile.rc, and the icon, i'll add that XP manifest to the rc file aswell. |
| ||
a batch file (.bat) is just a text file, when executed opens a command prompt and runs commands contained within the file. just name the batch file "build.bat" and open it. |
| ||
its telling me un reconized command, in the batch file i have:C:\USER1\Programs\MinGW/bin/windres -i res.rc -o res.o i'm using windows if it matters |
| ||
hmm, try replacing all the "\" slashes with "/" slashes. |
| ||
ahh i got it to work, i took out the dir, and just made it:windres -i res.rc -o res.o |
| ||
works great, it has the icon in the tray below, on the .exe, but its missing the icon on the window, any fixes? |
| ||
are you using max2d or maxgui? iv'e never tested it on the window created by graphics, works like a charm when using createwindow. i do know there is a way to set a windows icon by using its hwnd, but i cant remember the command.. |
| ||
max2d. |
| ||
i have no clue how to set the window icon when using graphics, i have something else i am working on so here's all i got, still not working though..SuperStrict Framework brl.glmax2d Import brl.blitz Import brl.random Import "res.o" ?Win32 Import "-lshell32" Extern "Win32" Function LoadIcon:Int(hWnd:Int, file$z, index:Int) = "ExtractIconA@12" Function SetClassLong:Int(hWnd:Int, nIndex:Int, dwNewLong:Int) = "SetClassLongA@12" Function FindWindowA:Int(WndClass$z, WndTitle$z) End Extern ? AppTitle = "GRAPHICS ICON" Graphics 800, 600 SetGraphicsDriver GLMax2DDriver() SetWindowIcon SetBlend LIGHTBLEND SetAlpha 0.4 While Not KeyDown(key_escape) SetColor Rnd(100), Rnd(100), Rnd(100) DrawOval Rnd(625), Rnd(600), Rnd(100, 200), Rnd(100, 200) Flip '; Delay 15 If AppTerminate() Then Exit Wend Function SetWindowIcon(IconID:Int = 0) ?Win32 Local hWnd:Int = FindWindowA("BlitzMax GLGraphics", AppTitle) ; DebugLog hWnd Local icon:Int = LoadIcon(hWnd, AppFile, IconID) ; DebugLog icon SetClassLong hWnd, -14, icon ? End Function also, the window class may differ if you're using a different graphics driver. |
| ||
hmm thanks for all the help plash. one of the links tonyg gave me looked like what i needed (by gray alien) but it didnt seem to work... i'v done some searching cant seem to find any diffenitive answers, anyone else care to share? |
| ||
What you want to achieve is a little hard. You will need to learn and research on MSDN as you try to combine the graphics window, which is NO application window with application features (window icon, system tray symbol). You would better trying it using MaxGUI or a different OS GUI module (bruceys wxMax for example) |
| ||
Does this not help? |
| ||
OH! that works, that post by grey alien! |
| ||
Yahfree, care to post exactly what you're doing to make it work? And also, is your solution compatible with Windows XP? Thanks. |
| ||
yes its compatible with windowsXP i copy windres.exe from minGW to a folder somewhere (i keep it by all my projects) along with my Icon, and my resfile.rc now you should have 3 files in this "IconMaker" folder: 1: icon.ico ;your icon (32x32 .ico) 2: resfile.rc ;with the lines: 101 ICON icon.ico 3: windres.exe ; from your MinGW/bin 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 now open a DOS window (command prompt) and drag and drop that build.bat file into the command prompt window. now press enter. and you'll have a new file in the "IconMaker" folder icon_import.o now import this into your bmax programs and that will give you your main icon. 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 calling it on command prompt. Now to get it on the window call the following function right after Graphics. ' ----------------------------------------------------------------------------- ' ccSetIcon ' ----------------------------------------------------------------------------- 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 |
| ||
tahnks for sharing this method, it just comes very handful :) has i have been recently trying to make this work with no results. |
| ||
Sorry my bad, I meant to say is it compatible with Vista? Thanks for posting the detailed instructions!! :) |
| ||
not sure, i'd like to know this though, if you have a vista machine to test it on. |
| ||
Grey's method works in Vista, as it's my main dev machine. |