- Home
·
- Graphics
·
- The code lets you implement Analog Clocks and Meters like the Windows clock setting arrangement.
The code lets you implement Analog Clocks and Meters like the Windows clock setting arrangement.
The code lets you implement Analog Clocks and Meters like the Windows clock setting arrangement.
Rate The code lets you implement Analog Clocks and Meters like the Windows clock setting arrangement.
(1(1 Vote))
Mmin As Double, Mmax As Double, Handw As Integer, Color As String, Handl As Double, _
Value As Double)
' The meter is assigned to a picture array (using Picture1).
' The Picture1 attributes are important. Set Scalemode = Pixel (3)
' Autosize = true
' Autoredraw = true
' Font Transparent = true
'
' Index = Which Meter to Adjust
' Mtype = Which Type of Meter it is (1=center dial, 2=half dial)
' EMin = Engineering Units Zero (Minimum)
' EMax = Engineering Units Span (Range)
' MMin = Minimum point on the meter face (0-60)
' MMax = Maximum point on the meter face (0-60)
' Handw = Thickness of dial hand (1,2,3)
' Color = Color of dial hand (vbRed, vbBlack)
' Handl = Length of the dial hand (0.1 is a good length)
' Value = The value to set the dial
If Mtype = 1 Then
Mdeg = 0 ' degrees (0-360)
cx = Picture1(Index).Width / 2
cy = Picture1(Index).Height / 2
End If
If Mtype = 2 Then
Mdeg = 270 ' degrees (0-360)
cx = Picture1(Index).Width / 2
cy = (Picture1(Index).Height - 2)
End If
r = IIf(cx > cy, cy, cx) - 5
sl = r * Handl 'length of meter hand
r1 = Emax - Emin
r2 = Mmax - Mmin
s = ((r2 / r1) * Value) + Mmin
sin_ = Sin((Mdeg - s * 6) * Deg2Rad) * (r - sl) + cx
cos_ = Cos((Mdeg - s * 6) * Deg2Rad) * (r - sl) + cy
oldcolor = vbBlack
Picture1(Index).ForeColor = Color
Picture1(Index).DrawWidth = Handw
Picture1(Index).Cls
Picture1(Index).Line (cx, cy)-(sin_, cos_)
Picture1(Index).ForeColor = oldcolor
End Sub
The code lets you implement Analog Clocks and Meters like the Windows clock setting arrangement. Comments
No comments yet — be the first to post one!
Post a Comment