Je pensai faire un fichier image.BMP, éventuellement ll transformer en ico ensuite le mettre dans le presse papier pour l'incorporer dans un dossier quelconque.
Mais j'ai un fichier image trés moche. avez vous d'autre idées ??
Code : Tout sélectionner
;MLD EXTACTEUR D'ICONES 30/09/2017
;***constantes***
#fenpr =0:#eticpres = 1:#eticexp1 = 2:#eticexp2 = 3:#eticexp3 = 4:#eticexp4 = 5:#eticexp5 = 6
#explorer = 10:#cadre1 = 11:#cadre2 = 12:#cadre3 = 13:#cadre4 = 14
#text1 = 20:#coche1 = 23:#coche2 = 24:#listico = 25:#conteneur = 26:#gadimg = 27
#btraz = 31:#btok = 32:btstop = 33
#txtinfofich1 = 40:#txtinfonbico3 = 41:#txtfich = 42:#txtnbico = 43:#txt_attente = 44
Global FontID1 = LoadFont(50,"Tahoma",14,#PB_Font_Bold)
Global FontID2 = LoadFont(51,"Tahoma",12,#PB_Font_HighQuality)
Global FontID3 = LoadFont(52,"Segoe Print",16,#PB_Font_HighQuality)
Global FontID4 = LoadFont(53,"Tahoma",8,#PB_Font_HighQuality)
Global FontID5 = LoadFont(54,"Segoe Print",32,#PB_Font_HighQuality)
Global nbf.f
Global nbico.q,flagico.b =1,icontrans
Global Dim tabicochem.s(0)
Macro couletic(gad)
SetGadgetFont(gad,FontID3)
SetGadgetColor(gad,#PB_Gadget_FrontColor,$8515C7)
SetGadgetColor(gad,#PB_Gadget_BackColor,$DCE4DC)
EndMacro
Procedure WindowProc(hWnd, msg, wParam, lParam)
If msg=#WM_CTLCOLORSTATIC
Select GetDlgCtrlID_(lParam)
Case 23 To 24
ProcedureReturn CreateSolidBrush_($DCE4DC)
EndSelect
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure Listico(fich$)
Protected j, icon,nbi.q
nbi.q = ExtractIconEx_(fich$, -1, #Null, #Null, #Null) - 1
If nbi <> -1
For j = 0 To nbi.q
If GetGadgetState(23)
z = ExtractIconEx_(fich$, j, #Null, @icon, 1) ;16x16
Else
z = ExtractIconEx_(fich$, j, @icon, #Null, 1) ;32x32 EndIf
EndIf
If z <> 0
nbico = nbico +1
ReDim tabicochem.s(nbico)
tabicochem.s(nbico)= fich$ +"," + Str(j)
AddGadgetItem(25, j,Str(CountGadgetItems(25)+1), icon)
EndIf
DestroyIcon_(icon)
Next
EndIf
EndProcedure
Structure InfoSDirectory
SubDirectories.i
Files.i
EndStructure
Define Info.InfoSDirectory
Procedure rech_ico(fich$, *Info.InfoSDirectory)
nbf = nbf +1
SetGadgetText(42,"F n°:"+ Str(nbf) + " " + fich$ )
Protected Numf.q
Numf.q = ExamineDirectory(#PB_Any, fich$, "*.*")
If Numf.q = 0
a$ = LCase(Right(fich$,3))
Select a$
Case "exe","dll","icl","ico"
Listico( fich$ )
EndSelect
Else
If Numf.q
While NextDirectoryEntry(Numf.q)
If DirectoryEntryName(Numf.q) <> "." And DirectoryEntryName(Numf.q) <> ".."
If DirectoryEntryType(Numf.q) = #PB_DirectoryEntry_File
a$ = LCase(Right(fich$ + "\" + DirectoryEntryName(Numf.q),3))
Select a$
Case "exe","dll","icl","ico"
Listico( fich$ + "\" + DirectoryEntryName(Numf.q))
EndSelect
Else
*Info\SubDirectories + 1
rech_ico(fich$ + "\" + DirectoryEntryName(Numf.q), *Info)
EndIf
EndIf
Wend
FinishDirectory(Numf.q)
EndIf
EndIf
EndProcedure
Procedure cdico()
nbf.f = 0:HideGadget(40,0):HideGadget(42,0):HideGadget(41,1):HideGadget(43,1):HideGadget(25,1):HideGadget(44,0)
ClearGadgetItems(25)
fich$ = GetGadgetText(20)
If fich$ = "Ce PC"
For I = 0 To 12 ; balaye l'alphabet
Lecteur.S = Chr(65 + I) + ":\"
ID = ExamineDirectory(#PB_Any, Lecteur, "*")
If ID
While WindowEvent() : Wend
rech_ico(Lecteur.S,@Info )
FinishDirectory(ID)
EndIf
Next
Else
While WindowEvent() : Wend
rech_ico(fich$,@Info)
EndIf
HideGadget(40,1):HideGadget(42,1):HideGadget(41,0):HideGadget(43,0):HideGadget(25,0):HideGadget(44,1)
SetGadgetText(43,Str(CountGadgetItems(25)))
EndProcedure
Procedure selectico(numico.q)
i$ = tabicochem.s(numico)
fich$ =StringField(i$,1,",")
j = Val(StringField(i$,2,","))
If GetGadgetState(23)
z = ExtractIconEx_(fich$, j, #Null, @icon, 1) ;16x16
Else
z = ExtractIconEx_(fich$, j, @icon, #Null, 1) ;32x32 EndIf
EndIf
If z <> 0
SetGadgetState(27,icon)
ID_Image = GetGadgetState(27)
CreateImage(500, 32, 32,32,#PB_Image_Transparent)
If StartDrawing(ImageOutput(500))
BackColor(RGBA(255,255,255,0))
DrawingMode(#PB_2DDrawing_Transparent)
DrawImage(ID_Image, 0, 0)
StopDrawing()
EndIf
SaveImage(500, "icone.bmp",#PB_ImagePlugin_BMP) ;c'est ici que ça coince ???????? l'image produite est trés moche.
EndIf
EndProcedure
OpenWindow(0,0,0,1600,900,"Ma Fenêtre",#PB_Window_BorderLess | #PB_Window_Invisible | #PB_Window_ScreenCentered)
SetWindowCallback(@WindowProc())
SetClassLongPtr_(WindowID(#fenpr),#GCL_STYLE,$00020000)
HideWindow(#fenpr,0)
SetWindowColor(#fenpr,$DCE4DC)
N$ = " EXTRACT | ICONES"
For x = 1 To Len(N$)
L$ = L$ + Mid(N$,x,1) + Chr(10)
Next
TextGadget(1,0,0,30,900,L$,#PB_Text_Center)
SetGadgetColor(1,#PB_Gadget_BackColor,$7FFF00)
SetGadgetFont(1,FontID1)
TextGadget(2,40,10,100,28,"Source")
TextGadget(3,40,530,100,28,"Taille")
TextGadget(4,40,610,200,28,"Sélection / Copie")
TextGadget(5,40,710,150,28,"Commandes")
TextGadget(6,380,10,150,28,"Icone(s)")
For gad = 2 To 6
couletic(gad)
Next
ExplorerTreeGadget(10,31,50,310,430, "",#PB_Explorer_NoMyDocuments|#PB_Explorer_GridLines|#PB_Explorer_AlwaysShowSelection )
SetGadgetColor(10,#PB_Gadget_BackColor,$DCE4DC)
SetGadgetColor(10,#PB_Gadget_FrontColor,$EE6E43)
SetGadgetColor(10,#PB_Gadget_LineColor,$13458B)
SetGadgetFont(10,FontID2)
FrameGadget(11,31,480,310,50,"",#PB_Frame_Flat)
FrameGadget(12,31,565,310,30,"",#PB_Frame_Flat)
FrameGadget(13,31,645,310,50,"",#PB_Frame_Flat)
FrameGadget(14,31,745,310,110,"",#PB_Frame_Flat)
TextGadget(20,32,481,308,40,"")
SetGadgetFont(20,FontID2)
SetGadgetColor(20,#PB_Gadget_BackColor,$DCE4DC)
SetGadgetColor(20,#PB_Gadget_FrontColor,$EE6E43)
OptionGadget(23,80,568,80,25,"16 X 16")
SetGadgetFont(23,FontID2)
OptionGadget(24,220,568,80,25,"32 X 32")
SetGadgetFont(24,FontID2)
SetGadgetState(24,1)
ContainerGadget(26,349,49,1231,806,#PB_Container_Double)
SetGadgetColor(26,#PB_Gadget_BackColor,$DCE4DC)
ListIconGadget(25,0,0,1230,804, "Column 1", 100)
SetGadgetColor(25,#PB_Gadget_BackColor,$DCE4DC)
SetGadgetAttribute(25, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
TextGadget(44,200,300,900,70,"Recherche et extraction d'icone(s)")
HideGadget(44,1)
SetGadgetColor(44,#PB_Gadget_BackColor,$DCE4DC)
SetGadgetFont(44,FontID5)
CloseGadgetList()
ImageGadget(27,160,655, 35, 35, 0)
ButtonGadget(31,35,801,150,45,"R A Z")
ButtonGadget(32,35,755,301,45,"Extraction")
ButtonGadget(33,186,801,150,45,"Stop")
For x = 30 To 33
SetGadgetFont(x,FontID2)
Next
TextGadget(40,40,865,180,28,"Examine fichiers:")
SetGadgetFont(40,FontID1)
SetGadgetColor(40,#PB_Gadget_FrontColor,$FF0000)
TextGadget(41,1330,865,100,28,"Icone(s):")
SetGadgetFont(41,FontID1)
SetGadgetColor(41,#PB_Gadget_FrontColor,$FF0000)
TextGadget(42,230,872,1200,20,"")
SetGadgetFont(42,FontID4)
SetGadgetColor(42,#PB_Gadget_FrontColor,$E22B8A)
TextGadget(43,1440,865,140,28,"")
SetGadgetFont(43,FontID1)
SetGadgetColor(43,#PB_Gadget_FrontColor,$FF0000)
For zz = 40 To 43
SetGadgetColor(zz,#PB_Gadget_BackColor,$DCE4DC)
HideGadget(zz,1)
Next
; Boucle générale
Repeat
Event = WaitWindowEvent(10)
If Event = #WM_LBUTTONDOWN
SendMessage_(WindowID(#fenpr), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
If Event = #PB_Event_Gadget
Select EventGadget()
Case 10 ;source
Select EventType()
Case #PB_EventType_LeftClick
If GetGadgetText(10) <> GetGadgetText(20) :ClearGadgetItems(25):EndIf
pathcible$ = GetGadgetText(10)
If pathcible$ = "":pathcible$ = "Ce PC":EndIf
SetGadgetText(20,pathcible$)
EndSelect
Case 23; 16 x 16
Dim tabicochem.s(0):nbico.q =0
SetGadgetState(23, 1)
cdico()
Case 24; 32 x 32
Dim tabicochem.s(0):nbico.q = 0
SetGadgetState(24, 1)
cdico()
Case 25
Select EventType()
Case #PB_EventType_LeftClick
item = GetGadgetState(25)
If item <> -1
numitem$ = GetGadgetItemText(25,item )
numitem.q = Val(numitem$)
selectico(numitem.q)
EndIf
EndSelect
Case 32
Dim tabicochem.s(0):nbico.q = 0
Dim tabicochem(0):nbico.q = 0
cdico()
Case 33 ;stop
FreeArray(tabicochem.s())
CloseWindow(0)
Break
EndSelect
EndIf
ForEver
End