forked from lee-soft/ViPad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RectHelper.bas
111 lines (79 loc) · 3.02 KB
/
RectHelper.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Attribute VB_Name = "RectHelper"
Option Explicit
Public Function IsRectL_Empty(ByRef theRect As GdiPlus.RECTL) As Boolean
If theRect.Left = 0 And theRect.Top = 0 And theRect.Width = 0 And theRect.Height = 0 Then
IsRectL_Empty = True
End If
End Function
Public Function GetWindowDimensions(ByRef theForm As Form) As RECTL
With GetWindowDimensions
.Top = theForm.Top / Screen.TwipsPerPixelY
.Left = theForm.Left / Screen.TwipsPerPixelX
.Height = theForm.ScaleHeight
.Width = theForm.ScaleWidth
End With
End Function
Public Function CreateRect(ByVal lBottom As Long, ByVal lRight As Long, ByVal lLeft As Long, ByVal lTop As Long) As win.RECT
Dim thisRect As RECTL
With CreateRect
.Bottom = lBottom
.Left = lLeft
.Top = lTop
.Right = lRight
End With
End Function
Public Function CreateRectF(Left As Long, Top As Long, Optional Height As Long, Optional Width As Long) As RECTF
Dim newRectF As RECTF
With newRectF
.Left = Left
.Top = Top
.Height = Height
.Width = Width
End With
CreateRectF = newRectF
End Function
Public Function CreateRectL(ByVal lHeight As Long, ByVal lWidth As Long, ByVal lLeft As Long, ByVal lTop As Long) As RECTL
Dim thisRect As RECTL
With CreateRectL
.Height = lHeight
.Left = lLeft
.Top = lTop
.Width = lWidth
End With
End Function
Public Function RECTWIDTH(ByRef srcRect As RECT)
RECTWIDTH = srcRect.Right - srcRect.Left
End Function
Public Function RECTHEIGHT(ByRef srcRect As RECT)
RECTHEIGHT = srcRect.Bottom - srcRect.Top
End Function
Public Function PrintRectF(ByRef srcRect As RECTF)
Debug.Print "Top; " & srcRect.Top & vbCrLf & _
"Left; " & srcRect.Left & vbCrLf & _
"Height; " & srcRect.Height & vbCrLf & _
"Width; " & srcRect.Width
End Function
Public Function PrintRect(ByRef srcRect As RECT)
Debug.Print "Top; " & srcRect.Top & vbCrLf & _
"Left; " & srcRect.Left & vbCrLf & _
"Bottom; " & srcRect.Bottom & vbCrLf & _
"Right; " & srcRect.Right
End Function
Public Function RECTtoF(ByRef srcRECTL As RECT) As RECTF
RECTtoF = CreateRectF(CLng(srcRECTL.Left), CLng(srcRECTL.Top), CLng(srcRECTL.Bottom), CLng(srcRECTL.Right))
End Function
Public Function RECTFtoL(ByRef srcRect As RECTF) As RECT
RECTFtoL = CreateRect(CLng(srcRect.Left), CLng(srcRect.Top), CLng(srcRect.Height), CLng(srcRect.Width))
End Function
Public Function RECTLtoF(ByRef srcRECTL As RECTL) As RECTF
RECTLtoF = CreateRectF(CLng(srcRECTL.Left), CLng(srcRECTL.Top), CLng(srcRECTL.Height), CLng(srcRECTL.Width))
End Function
Public Function PointInsideOfRect(srcPoint As win.POINTL, srcRect As win.RECT) As Boolean
PointInsideOfRect = False
If srcPoint.Y > srcRect.Top And _
srcPoint.Y < srcRect.Bottom And _
srcPoint.X > srcRect.Left And _
srcPoint.X < srcRect.Right Then
PointInsideOfRect = True
End If
End Function