Note: My real app doesn't quit, but just needs to free the icons when I want. Also, I can't hard-code the icons because there can any random amount of them created at any given time, from 1 to 999; and also the user will be specifying any file to get them, like the "exe" case below.
Thanks!
Code: Select all
CreateImage(1,32,32,24,#Red) ; A global image to use many times.
Procedure GetIcon(which$)
Select which$
Case "red" : i=ImageID(1)
Case "exe" : i=ExtractIcon_(0,"c:\windows\regedit.exe",0)
EndSelect
ProcedureReturn i
EndProcedure
icon1=GetIcon("red")
Debug icon1 ; 65579
Debug IsImage(icon1) ; 0
icon2=GetIcon("exe")
Debug icon2 ; 78775965
Debug IsImage(icon2) ; 0
OpenWindow(0,400,300,60,60,"Icons")
ImageGadget(1,10,10,16,16,icon1)
ImageGadget(2,50,10,16,16,icon2)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
FreeImage(icon1) ; The specified #Image is not initialised.
FreeImage(icon2) ; The specified #Image is not initialised.