Page 1 of 1

Icon Extract

Posted: Sat Oct 15, 2005 9:32 pm
by Droopy
Code updated For 5.20+

I know it's easy but here's the code :

Code: Select all

; Idea from Rikuk
; File specifies the file where icon is extracted
; icon = 0 to ? --> Return handle of image
; icon = -1 --> Return the count of icon

Procedure IconExtract(File.s,Icon)
  ProcedureReturn ExtractIcon_(0,File,Icon)
EndProcedure

;/ Test
#file="C:\WINDOWS\explorer.exe"
Count=IconExtract(#file,-1)
OpenWindow(0,0,0,130,70,Str(Count)+" Icons",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)

ButtonImageGadget(0,10,10,48,48,IconExtract(#file,pointer))
TextGadget(1,80,30,40,20,"n° 1")


Repeat
  event=WaitWindowEvent()
  
  If event= #PB_Event_Gadget And EventGadget()=0 And EventType()=#PB_EventType_LeftClick
    pointer+1
    If pointer=Count : pointer=0 : EndIf
    SetGadgetState(0,IconExtract(#file,pointer))
    SetGadgetText(1,"n° "+Str(pointer+1))
  EndIf
Until event=#PB_Event_CloseWindow

Posted: Sun Oct 16, 2005 3:05 pm
by srod
Nice example Droopy. That will come in handy.

Re: Icon Extract

Posted: Sun Oct 16, 2005 5:22 pm
by NoahPhense
Nice..

- np