-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathRectHelper.bas
More file actions
99 lines (73 loc) · 2.94 KB
/
RectHelper.bas
File metadata and controls
99 lines (73 loc) · 2.94 KB
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
Attribute VB_Name = "RectHelper"
'--------------------------------------------------------------------------------
' Component : RectHelper
' Project : ViDock
'
' Description: Contains helper functions for RECTs and RECTFs
'
'--------------------------------------------------------------------------------
Option Explicit
Public Function RECTWIDTH(ByRef srcRect As Win.RECT)
RECTWIDTH = srcRect.Right - srcRect.Left
End Function
Public Function RECTHEIGHT(ByRef srcRect As Win.RECT)
RECTHEIGHT = srcRect.Bottom - srcRect.Top
End Function
Public Function PrintRectF(ByRef srcRect As gdiplus.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 gdiplus.RECTF
RECTtoF = CreateRectF(CLng(srcRECTL.Left), CLng(srcRECTL.Top), CLng(srcRECTL.Bottom), CLng(srcRECTL.Right))
End Function
Public Function RECTFtoL(ByRef srcRect As gdiplus.RECTF) As gdiplus.RECTL
RECTFtoL = CreateRectL(srcRect.Height, srcRect.Width, srcRect.Left, srcRect.Top)
End Function
Public Function RECTLtoF(ByRef srcRECTL As gdiplus.RECTL) As gdiplus.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
Public Function CreateRect(Left As Long, _
Top As Long, _
Bottom As Long, _
Right As Long) As RECT
Dim newRect As RECT
With newRect
.Left = Left
.Top = Top
.Bottom = Bottom
.Right = Right
End With
CreateRect = newRect
End Function
Public Function CreateRectL(ByVal lHeight As Long, _
ByVal lWidth As Long, _
ByVal lLeft As Long, _
ByVal lTop As Long) As gdiplus.RECTL
With CreateRectL
.Height = lHeight
.Left = lLeft
.Top = lTop
.Width = lWidth
End With
End Function
Public Function CreateRectF(Left As Single, _
Top As Single, _
Height As Single, _
Width As Single) As gdiplus.RECTF
Dim newRectF As gdiplus.RECTF
With newRectF
.Left = Left
.Top = Top
.Height = Height
.Width = Width
End With
CreateRectF = newRectF
End Function