Here a little procedure to change the application icon anytime after the start.
Code: Select all
; (c) 2001 - Franco's template - absolutely freeware
; How to change an application icon on the fly
Procedure ChangeAppIcon(Image$)
hIco=LoadImage(0,Image$)
SetClassLong_(WindowID(),#GCL_HICON,hIco)
EndProcedure
;test
If OpenWindow(0, 200, 200, 320,240, #PB_Window_SystemMenu ,"Test Window")
ChangeAppIcon(".\myicon.ico") ; <- your icon name...
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
EndIf
End
You can also make an animated icon (you need 32 different icons)
PureBasic is fast enough for this!
BUT you have to put a DELAY(x) command in the procedure!!!
Otherwise nasm will KILL your OS!!! (tested on Win98)
Code: Select all
; (c) 2001 - Franco's template - absolutely freeware
; how to make an animated application icon
Procedure AnimatedAppIcon(Image$)
Icon=1 ; <- icon name must be something like icon_1.ico to icon_32.ico
Repeat
hIco=LoadImage(0,Image$+Str(Icon)+".ico")
SetClassLong_(WindowID(),#GCL_HICON,hIco)
Icon=Icon+1 : If Icon=32 : Icon=1 : EndIf
Delay(50) ;<- don't delete this, otherwise nasm will crash!
ForEver
EndProcedure
;test
If OpenWindow(0, 200, 200, 320,240, #PB_Window_SystemMenu ,"Test Window")
CreateThread(@AnimatedAppIcon(),".\icon_") ; <- without extension!
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
EndIf
Have a nice day...
Franco