localmotion34 wrote:
did you use my LEDgadget and graph source in this?
Hello localmotion34. Actually I use a code you've posted some time ago already. That is exactly what I needed for my program. I used the source code for this post I've adapted with my application. This is very useful for this type of view. Thank you for that
http://www.purebasic.fr/english/viewtopic.php?f=12&t=24528&hilit=ledgadgetCode:
;-------------------------------------------------------
;-LED gadget
;-------------------------------------------------------
;{
Structure gauge
imagegad.l
imageid.l
width.l
height.l
imagehwnd.l
precision.l
ticks.l
textgad.l
texthwnd.l
state.l
numstates.l
EndStructure
;- LED Gadget
Procedure LEDgadget(number,x,Y,width,height,DisplayColor)
*led.gauge =ReAllocateMemory(*led.gauge,SizeOf(gauge))
*led\width=width
*led\height=height
*led\imageid=CreateImage(#PB_Any,*led\width,*led\height)
StartDrawing(ImageOutput(*led\imageid))
Box(0,0,*led\width,*led\height,#Black)
ledheight=*led\height-20
boxwidth=(*led\width-10-1)/2
secondx= 6+boxwidth
tickcount=0
For a=0 To *led\height-20 Step 4
tickcount=tickcount+1
Box(5,a,boxwidth,3,$7F00)
Box(secondx,a,boxwidth,3,$7F00)
Next
*led\ticks=tickcount
BackColor(RGB(0,0,0))
FrontColor(RGB(0, $FF, 0))
DrawText((*led\width/2)-10,*led\height-15,"0%")
StopDrawing()
StaticCtl.l=ImageGadget(number,x,Y,width,height,ImageID(*led\imageid),#PB_Image_Border)
If number=#PB_Any
*led\imagegad=StaticCtl
SetWindowLong_(GadgetID(StaticCtl),#GWL_USERDATA,*led.gauge)
ProcedureReturn *led\imagegad
Else
*led\imagegad=number
SetWindowLong_(GadgetID(number),#GWL_USERDATA,*led.gauge)
ProcedureReturn StaticCtl
EndIf
EndProcedure
Procedure setLEDstate(led,percent)
*led.gauge=GetWindowLong_(GadgetID(led),#GWL_USERDATA)
tickcount=*led\ticks
perc.f=100/*led\ticks
percents.f=(percent/100)
finalpercent.f=percents*tickcount
stringpercent.s=StrF(finalpercent)
Result.f = Round(finalpercent, 1)
finalresult=*led\ticks-Result
ledheight=*led\height-20
boxwidth=(*led\width-10-1)/2
secondx=6+boxwidth
ImageID(*led\imageid)
StartDrawing(ImageOutput(*led\imageid))
tickcount=0
For a=0 To *led\height-20 Step 4
tickcount=tickcount+1
If tickcount>=finalresult
Box(5,a,boxwidth,3,$FF00)
Box(secondx,a,boxwidth,3,$FF00)
Else
Box(5,a,boxwidth,3,$7F00)
Box(secondx,a,boxwidth,3,$7F00)
EndIf
Next
Box(0,*led\height-15,*led\width,15,#Black)
BackColor(RGB(0,0,0))
FrontColor(RGB(0, $FF, 0))
DrawText((*led\width/2)-10,*led\height-15,Str(percent)+" %")
StopDrawing()
SetGadgetState(*led\imagegad,ImageID(*led\imageid))
EndProcedure
;}