Code archives/Miscellaneous/Icon in Top Left corner of Window
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This code sets the icon in the top left of the window. It also sets the icon on the task bar, and the correct icon for when alt+tabbing. You must have an icon file with the same name as your app in the same folder: [edit] btw FindWindowA can be replaced with GetActiveWindow() with no parameters required, which is better actually. Hope you find this useful! | |||||
Strict Extern "win32" Function FindWindowA:Int(nullstring%,WindowText$z) Function ExtractIconA:Int(hWnd%,File$z,Index%) Function SetClassLongA:Int(hWnd%,nIndex%,Value%) End Extern AppTitle = "test" Graphics 640,480,0 'Graphics 640,480,32 Local handle:Int = FindWindowA(0,"test") ccSetIcon(StripExt(ccAppFileNonDebug())+".ico",handle) Repeat Cls Flip Until KeyDown(Key_Escape) Function ccSetIcon(iconname$, TheWindow%) Local icon=ExtractIconA(TheWindow,iconname,0) SetClassLongA(TheWindow,-14,icon) End Function Function ccAppFileNonDebug$() 'Returns AppFile but without the .debug on the end when running in debug mode. If Mid(AppFile,Len(AppFile)-8, 5) = "debug" Then Return Mid(AppFile,1,Len(AppFile)-10)+".exe" 'chops off .debug.exe (10 chars) Else Return AppFile EndIf End Function |
Comments
| ||
um, i dont have or understand blizt max but isnt this the same thing |
| ||
oh yes, it does the same thing. I converted mine from my Blitz Plus code. |
| ||
I tried the code above and it changed the icon on the taskbar, but not the icon in the top left corner. |
| ||
Is there a Blitz3d version? |
| ||
cal: it works for me, how odd... Boiled Sweets: It's easy to convert to B3D, but there must be something in the archives for BPlus that will compile into B3D. |
Code Archives Forum