J'ai commencer a faire mon petit slider (potentiometre) comme l'image ci-dessous. Bon c'est vraiment le debut mais bon il est redimentionnable c'est deja cela


Et voila le code-source (enfin le debut test). Donner moi vos avis.
Code : Tout sélectionner
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
;- INITIALISATION DES DIRECTIVES COMPILEUR.
DisableASM
EnableExplicit
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
;- DECLARATION DES VARIABLES (GLOBALE).
;{ - CONSTANTES
#WinMinX = 640
#WinMinY = 506
#WinLenX = 800
#WinLenY = 600
;}
;{ - ENUMERATION
Enumeration
#Window_0
EndEnumeration
Enumeration
#picture_0
EndEnumeration
;}
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure DMXSliderGadget(gadget.l, x.l, y.l, w.l, h.l, etat.l, min.l, max.l)
; ROUTINE DE GETION DES BOUTONS.
Protected i.l
Protected tmpa.l
Protected tmpb.l
Protected tmpc.l
Protected pasa.f
Protected pasb.f
Protected pasc.f
Protected mula.f
Protected mulb.f
Protected mulc.f
If CreateImage(#picture_0, w, h)
If StartDrawing(ImageOutput(#picture_0))
tmpa = w/2
Box(0, 0, w, h, $f9f3ed)
Box(tmpa-1, 0, 2, h, $d5b08c)
LineXY(tmpa-1, 0, tmpa-1, h, $8e6235)
LineXY(tmpa-1, 0, tmpa , 0, $8e6235)
LineXY(tmpa+1, 0, tmpa+1, h, $e9d6c2)
LineXY(tmpa, h-1, tmpa+1, h-1,$e9d6c2)
tmpb = max - min
pasa = h / tmpb
For i=0 To h
LineXY(0, i, tmpa-4, i, $d5b08c)
LineXY(tmpa+4, i, w, i, $d5b08c)
i + (pasa * 4)
Next i
tmpa = w/10
Box(0, 0+etat, w, w+tmpa, $8e6235)
Box(1, 1+etat, w-2, w+tmpa-2, $e6d0b9)
Box(2, 2+etat, w-4, w+tmpa-4, $d5b08c)
tmpb = (w/6)-1
pasa = (Red($8e6235) - Red($b88957)) / tmpb : mula = Red($8e6235)
pasb = (Green($8e6235) - Green($b88957)) / tmpb : mulb = Green($8e6235)
pasc = (Blue($8e6235) - Blue($b88957)) / tmpb : mulc = Blue($8e6235)
For i = 1 To tmpb Step 1
mula = mula - pasa
mulb = mulb - pasb
mulc = mulc - pasc
LineXY(1, i+etat, w-2, i+etat, RGB(mula,mulb,mulc))
LineXY(1, (w+tmpa-1)-i+etat, w-2, (w+tmpa-1)-i+etat, RGB(mula,mulb,mulc))
Next i
LineXY(1, tmpb+1+etat, w-2, tmpb+1+etat, $dcbd9e)
LineXY(1, (w+tmpa)-tmpb-2+etat, w-2, (w+tmpa)-tmpb-2+etat, $dcbd9e)
LineXY(1, ((w+tmpa)/2)+etat, w-2, ((w+tmpa)/2)+etat, $c69662)
LineXY(1, ((w+tmpa)/2)-1+etat, w-2, ((w+tmpa)/2)-1+etat, $e9d6c2)
tmpc = ((w+tmpa)/2) - (tmpb * 2)
pasa = (Red($d5b08c) - Red($e9d6c2)) / tmpc : mula = Red($e9d6c2)
pasb = (Green($d5b08c) - Green($e9d6c2)) / tmpc : mulb = Green($e9d6c2)
pasc = (Blue($d5b08c) - Blue($e9d6c2)) / tmpc : mulc = Blue($e9d6c2)
For i = 1 To tmpc Step 1
mula = mula + pasa
mulb = mulb + pasb
mulc = mulc + pasc
LineXY(3, tmpb+1+i+etat, w-4, tmpb+1+i+etat, RGB(mula,mulb,mulc))
LineXY(3, (w+tmpa)-tmpb-2-i+etat, w-4, (w+tmpa)-tmpb-2-i+etat, RGB(mula,mulb,mulc))
Next i
StopDrawing()
EndIf
SetGadgetState(#picture_0, ImageID(#picture_0))
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Define i.l
Define event.l
Define hWnd.l = OpenWindow(#Window_0, 0, 0, #WinLenX, #WinLenY, "", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered | #PB_Window_Maximize)
If hWnd <> 0
SmartWindowRefresh(#Window_0, 1)
ImageGadget(#picture_0, 200, 256, 24, 200, 0)
Repeat
event = WaitWindowEvent(50)
i+1
If i> 230
i=0
EndIf
DMXSliderGadget(0, 0, 0, 24, 256, i, 0, 255)
Until event = #PB_Event_CloseWindow
EndIf
GallyHC