Icon Extract

Share your advanced PureBasic knowledge/code with the community.
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Icon Extract

Post 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
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Nice example Droopy. That will come in handy.
I may look like a mule, but I'm not a complete ass.
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: Icon Extract

Post by NoahPhense »

Nice..

- np
Post Reply