VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



The code lets you implement Analog Clocks and Meters like the Windows clock setting arrangement.

by Pooja N (1 Submission)
Category: Graphics
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 25th March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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.



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




Download this snippet    Add to My Saved Code

The code lets you implement Analog Clocks and Meters like the Windows clock setting arrangement. Comments

No comments have been posted about The code lets you implement Analog Clocks and Meters like the Windows clock setting arrangement.. Why not be the first to post a comment about The code lets you implement Analog Clocks and Meters like the Windows clock setting arrangement..

Post your comment

Subject:
Message:
0/1000 characters