This is a work in process, and I'm improving it in the coming days/weeks. Right now it has a big weakness, that is that I'm using the image rotation library of Mischa to point the needles, and this type of rotation, while nice and fast, can appear somewhat poor quality depending on what number the needle is pointing at. I can replace this approach with another one and improve the image quality dramatically, but it's hours of work and I have to see how many people are interested in it before I commit to it.
Anyway, the dll has two functions: _nm_DrawDial and _nm_GetState.
You pick a static image# to use for a dial and call the dll as such:
Callfunction(#Library, "_nm_DrawDial", #image, state.l, backcolor.l)
-You don't create the #image first, the dll will do that. Just pass it a number you want used for the dial.
- State is a number 0-80, numbers outside this range get changed to 0 or 80 depending on whether they were too high or too low.
-Backcolor is a color to paint the box around the round dial so it shows transparent on your window. My windows are RGB(224,223,227) and so that's what I send it in the code example.
CallFunction(#Library, "_nm_GetState, #dial)
- #dial is the #image you used to create the dial, pass the function that number and it will give you back a long containing the current number the needle on the dial is pointing at.
Here is the dll: http://www.networkmaestro.com/dial.dll
And here is an example program just for fun:
Code: Select all
OpenWindow(0,0,0,480,300,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowColor(0,RGB(224,223,227))
CreateGadgetList(WindowID(0))
OpenLibrary(0,"dial.dll")
image1 = CallFunction(0,"_nm_DrawDial",0,40,RGB(224,223,227))
image2 = CallFunction(0,"_nm_DrawDial",1,0,RGB(224,223,227))
ImageGadget(0,50,50,152,152,image1)
ImageGadget(1,250,50,152,152,image2)
TextGadget(2,120,210,40,22,"")
TextGadget(3,320,210,40,22,"")
i=0
fwd=#True
time = ElapsedMilliseconds()
Repeat
;first image
If ElapsedMilliseconds()-time >= 1000
image1 = CallFunction(0,"_nm_DrawDial",0,Random(80),RGB(224,223,227))
SetGadgetState(0,image1)
time=ElapsedMilliseconds()
SetGadgetText(2,Str(CallFunction(0,"_nm_GetState",0)))
EndIf
If fwd
i+1:If i>80:fwd=#False:EndIf
Else
i-1:If i<0:fwd=#True:EndIf
EndIf
;secondimage
image2 = CallFunction(0,"_nm_DrawDial",1,i,RGB(224,223,227))
SetGadgetState(1,image2)
SetGadgetText(3,Str(CallFunction(0,"_nm_GetState",1)))
Delay(1)
Until WindowEvent()=#WM_CLOSE
CloseLibrary(0)
End
Hope you enjoy it!
