by ORG (1 Submission)
Category: Graphics
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 11th March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Draws horizontal Ruler.
Public Sub DrawRulerH(Obj As Object, X As Long, Y As Long, Length As Long, sUnit As String)
Dim Height As Long, Devide As Long
Dim SmallSteps As Long, bSwitch As Boolean
Dim h1 As Long, TwpPerUnit As Long
Dim TmpK1 As Long
Dim K1 As Long, K2 As Long, N As Long
Obj.DrawStyle = vbSolid: Obj.DrawWidth = 1: Obj.DrawMode = vbCopyPen
Obj.ScaleMode = vbTwips: Obj.FontSize = 8
Obj.ForeColor = vbBlack
Height = 400
If UCase(sUnit) = "INCH" Then
TwpPerUnit = 1440
Devide = 20
Else
'CM
TwpPerUnit = 567
Devide = 6
End If
SmallSteps = TwpPerUnit / Devide
Obj.Line (X, Y)-(X + Length, Y)
Obj.Line (X, Y + Height)-(X + Length, Y + Height)
N = -1
For K1 = 0 To Length Step TwpPerUnit
bSwitch = True: N = N + 1
Obj.Line (X + K1, Y)-(X + K1, Y + Height + 50), vbRed
''''''
'following two lines draw aero head
Obj.Line (X + K1, Y + Height + 50)-(X + K1 - 50, Y + Height + 50 - 100), vbRed
Obj.Line (X + K1, Y + Height + 50)-(X + K1 + 50, Y + Height + 50 - 100), vbRed
Obj.CurrentY = Y + 30
Obj.CurrentX = Obj.CurrentX + 20 - Obj.TextWidth(Str(N)) / 2
If K1 = 0 Then Obj.Print "0 " + Mid(sUnit, 1, 2) + "." Else Obj.Print N
Obj.Line (X + K1 + TwpPerUnit / 2, Y)-(X + K1 + TwpPerUnit / 2, Y + Height)
For K2 = TmpK1 + SmallSteps To K1 - SmallSteps Step SmallSteps
bSwitch = Not bSwitch
If bSwitch Then
Obj.Line (X + K2, Y + Height - 200)-(X + K2, Y + Height)
Else
Obj.Line (X + K2, Y + Height - 100)-(X + K2, Y + Height)
End If
Next K2
TmpK1 = K1
Next K1
End Sub
'OR Ghimire, [email protected]
'Ktm, Npl