






@++
Code : Tout sélectionner
Enumeration
#Window_0
EndEnumeration
Enumeration
#Frame3D_0
#IPAddress_0
#Button_0
#ProgressBar_0
#Button_1
#TrackBar_0
#Frame3D_2
#Frame3D_3
#Frame3D_4
#Text_1
#Text_2
#Text_3
#Image
#im_barre_progress
EndEnumeration
LoadImage(#Image, "c:/test.bmp")
Procedure CallBack(Hnd,Msg,wParam,lParam)
Resultat = #PB_ProcessPureBasicEvents
If Msg = #WM_PAINT
ps.PAINTSTRUCT
hdc=BeginPaint_(Hnd, ps)
hdc_source=CreateCompatibleDC_(hdc)
SelectObject_(hdc_source,UseImage(#Image))
BitBlt_(hdc, 0, 0, 600, 400,hdc_source, 0, 0, #SRCCOPY)
EndPaint_(Hnd,ps)
DeleteDC_(hdc_source)
EndIf
ProcedureReturn Resultat
EndProcedure
Procedure Copy_fichier()
If CreateImage(#im_barre_progress, 346, 13)
If StartDrawing(ImageOutput())
StopDrawing()
EndIf
Repeat
i=i+1
Delay(100)
If StartDrawing(ImageOutput())
Box(0, 0, 346, 13,RGB(239,170,92))
Box(0, 0, i*3.46, 13,RGB(40,185,56))
FrontColor(0,0,0)
DrawingMode(1)
Locate(0,-1)
DrawText(" fichier.txt "+Str(i))
StopDrawing()
EndIf
SetGadgetState(#im_barre_progress,ImageID())
;MessageRequester("","",0)
Until i=100
EndIf
thread=0
EndProcedure
If OpenWindow(#Window_0, 303, 103, 485, 250, #PB_Window_SizeGadget|#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "virtual cb")
If CreateGadgetList(WindowID())
ButtonGadget(#Button_1, 280, 170, 170, 30, "lancer", #PB_Button_Toggle)
ImageGadget(#im_barre_progress, 26,98, 346,10, 0)
SetWindowCallback(@CallBack())
EndIf
EndIf
InvalidateRect_(WindowID(0),0,1)
Repeat
event = WaitWindowEvent()
If event = #PB_EventGadget
Select EventGadgetID()
Case #Button_1
ThreadID=CreateThread(@Copy_fichier(),ess)
EndSelect
EndIf
Until event = #PB_EventCloseWindow
Code : Tout sélectionner
Enumeration
#Window_0
EndEnumeration
Enumeration
#Frame3D_0
#IPAddress_0
#Button_0
#ProgressBar_0
#Button_1
#TrackBar_0
#Frame3D_2
#Frame3D_3
#Frame3D_4
#Text_1
#Text_2
#Text_3
#Image
#im_barre_progress
EndEnumeration
UseJPEGImageDecoder()
LoadImage(#Image, "D:\PureBasic\Compilers\collines.jpg")
Procedure CallBack(Hnd,msg,wParam,lParam)
Resultat = #PB_ProcessPureBasicEvents
If msg = #WM_PAINT
UseImage(#Image);<------- ici
ps.PAINTSTRUCT
hdc=BeginPaint_(Hnd, ps)
hdc_source=CreateCompatibleDC_(hdc)
SelectObject_(hdc_source,UseImage(#Image))
BitBlt_(hdc, 0, 0, 600, 400,hdc_source, 0, 0, #SRCCOPY)
EndPaint_(Hnd,ps)
DeleteDC_(hdc_source)
EndIf
ProcedureReturn Resultat
EndProcedure
Procedure Copy_fichier()
If CreateImage(#im_barre_progress, 346, 13)
; If StartDrawing(ImageOutput())
;
; StopDrawing()
; EndIf
Repeat
i=i+1
Delay(100)
UseImage(#im_barre_progress) ;<----- ici
If StartDrawing(ImageOutput())
Box(0, 0, 346, 13,RGB(239,170,92))
Box(0, 0, i*3.46, 13,RGB(40,185,56))
FrontColor(0,0,0)
DrawingMode(1)
Locate(0,-1)
DrawText(" fichier.txt "+Str(i))
StopDrawing()
EndIf
SetGadgetState(#im_barre_progress,ImageID())
;MessageRequester("","",0)
Until i=100
EndIf
thread=0
EndProcedure
If OpenWindow(#Window_0, 303, 103, 485, 250, #PB_Window_SizeGadget|#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "virtual cb")
If CreateGadgetList(WindowID())
ButtonGadget(#Button_1, 280, 170, 170, 30, "lancer", #PB_Button_Toggle)
ImageGadget(#im_barre_progress, 26,98, 346,10, 0)
SetWindowCallback(@CallBack())
EndIf
EndIf
InvalidateRect_(WindowID(0),0,1)
Repeat
event = WaitWindowEvent()
If event = #PB_EventGadget
Select EventGadgetID()
Case #Button_1
ThreadID=CreateThread(@Copy_fichier(),ess)
EndSelect
EndIf
Until event = #PB_EventCloseWindow
Oui j'ai pris l'habitute de faire cela, comme ça, je sais quelle image mettre dans quel gadget, et cela à l'air de marcher.Tu as un ImageGadget() nommé #im_barre_progress, et tu crée une image en lui donnant le même nom, et donc, le même index que ton gadget).