Title Bar Icon...
Blitz3D Forums/Blitz3D Programming/Title Bar Icon...
| ||
Is there a way to replace the title bar icon of windowed games in Blitz3D? |
| ||
Yes, use Resource Hacker to replace the icon in your compiled .exe: http://angusj.com/resourcehacker/ Note: you have to do this every time you create a new version of the executable. |
| ||
I have changed the .exe icon already. The icon I am refering to is the small rectangle on a windowed game in the uper left hand corner just before the apptitle ;) |
| ||
here is example program and DECLS file Example progy: ============== ;************************************************************************************************************** ; ; Set window icon funcs v1.2 by Kefir, mail:pinkefir@... ; ;************************************************************************************************************** Const ICON_SMALL = 0 Const ICON_BIG = 1 Const WM_SETICON = 128 Const LR_DEFAULTCOLOR = 0 Const LR_LOADFROMFILE = 16 Global PrevProgramIcon = 0 Global PrevAltTabIcon = 0 ;Internal use function Function SetWindowIcon(WindowHandle, IconHandle, IconType) api_SendMessage(WindowHandle, WM_SETICON, IconType, IconHandle) End Function ;Set the window's system menu icon Function SetProgramIcon(WindowHandle, FileName$, IconW=16, IconH=16) If PrevProgramIcon>0 Then api_DestroyIcon(PrevProgramIcon) PrevSysMenuIcon = api_LoadImage(0, FileName$, 1, IconW, IconH, LR_LOADFROMFILE) SetWindowIcon(WindowHandle, PrevSysMenuIcon, ICON_SMALL) End Function ;Set the icon what used in the window that occurs when you press Alt+TAB Function SetAltTabIcon(WindowHandle, FileName$, IconW=32, IconH=32) If PrevAltTabIcon>0 Then api_DestroyIcon(PrevAltTabIcon) PrevAltTabIcon = api_LoadImage(0, FileName$, 1, IconW, IconH, LR_LOADFROMFILE) SetWindowIcon(WindowHandle, PrevAltTabIcon, ICON_BIG) End Function ;Set icons extracted from .exe or .dll, IconIndex - index of icon in resource file Function SetProgramIconEx(WindowHandle, ImageName$, IconIndex=0, IconW=16, IconH=16) If PrevProgramIcon>0 Then api_DestroyIcon(PrevProgramIcon) PrevSysMenuIcon = api_LoadImage(api_GetModuleHandle(0), ImageName, 1, IconW, IconH, LR_DEFAULTCOLOR) SetWindowIcon(WindowHandle, PrevSysMenuIcon, ICON_SMALL) End Function Function SetAltTabIconEx(WindowHandle, ImageName$, IconIndex=0, IconW=32, IconH=32) If PrevAltTabIcon>0 Then api_DestroyIcon(PrevAltTabIcon) PrevAltTabIcon = api_LoadImage(api_GetModuleHandle(0), ImageName, 1, IconW, IconH, LR_DEFAULTCOLOR) SetWindowIcon(WindowHandle, PrevAltTabIcon, ICON_BIG) End Function ;Example-------------------------------------------------------------------------------- ;Get application window handle WindowHandle = api_GetActiveWindow() ;Set application title AppTitle "Test icon program" Print "Number of icons in executable: " + api_ExtractIcon(WindowHandle, "SetProgramIcon.exe", -1) ;Setting the icon SetProgramIcon(WindowHandle, "icon.ico"); NOTE: image must be an .ico file SetAltTabIcon(WindowHandle, "icon.ico") Print "Press any key to change current icon..." WaitKey SetProgramIcon(WindowHandle, "icon2.ico") SetAltTabIcon(WindowHandle, "icon2.ico") Print "Press any key to exit..." WaitKey DECLS file: =========== .lib "kernel32.dll" api_GetModuleHandle% (lpModuleName%) : "GetModuleHandleA" .lib "user32.dll" api_GetActiveWindow% () : "GetActiveWindow" api_LoadImage% (hInst%, lpsz$, un1%, n1%, n2%, un2%) : "LoadImageA" api_DestroyIcon% (hIcon%) : "DestroyIcon" api_SendMessage% (hwnd%, wMsg%, wParam%, lParam%) : "SendMessageA" 'njoyy :) |
| ||
Great!! Thanks Naughty Alien!! :) |