-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathborderless resize (long).txt
executable file
·190 lines (171 loc) · 7.25 KB
/
borderless resize (long).txt
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
Imports System.Text
Imports System.Data
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.Collections.Generic
Public Class Form1
Dim maximized As Boolean
Dim on_MinimumSize As Boolean
Dim minimumWidth As Short = 350
Dim minimumHeight As Short = 26
Dim borderSpace As Short = 20
Dim borderDiameter As Short = 3
Dim onBorderRight As Boolean
Dim onBorderLeft As Boolean
Dim onBorderTop As Boolean
Dim onBorderBottom As Boolean
Dim onCornerTopRight As Boolean
Dim onCornerTopLeft As Boolean
Dim onCornerBottomRight As Boolean
Dim onCornerBottomLeft As Boolean
Dim movingRight As Boolean
Dim movingLeft As Boolean
Dim movingTop As Boolean
Dim movingBottom As Boolean
Dim movingCornerTopRight As Boolean
Dim movingCornerTopLeft As Boolean
Dim movingCornerBottomRight As Boolean
Dim movingCornerBottomLeft As Boolean
Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles MyBase.MouseUp
stopResizer()
End Sub
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles MyBase.MouseDown
If e.Button = MouseButtons.Left Then
If onBorderRight Then
movingRight = True
Else
movingRight = False
End If
If onBorderLeft Then
movingLeft = True
Else
movingLeft = False
End If
If onBorderTop Then
movingTop = True
Else
movingTop = False
End If
If onBorderBottom Then
movingBottom = True
Else
movingBottom = False
End If
If onCornerTopRight Then
movingCornerTopRight = True
Else
movingCornerTopRight = False
End If
If onCornerTopLeft Then
movingCornerTopLeft = True
Else
movingCornerTopLeft = False
End If
If onCornerBottomRight Then
movingCornerBottomRight = True
Else
movingCornerBottomRight = False
End If
If onCornerBottomLeft Then
movingCornerBottomLeft = True
Else
movingCornerBottomLeft = False
End If
End If
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles MyBase.MouseMove
If maximized Then
Return
End If
If Me.Width <= minimumWidth Then
Me.Width = (minimumWidth + 5)
on_MinimumSize = True
End If
If Me.Height <= minimumHeight Then
Me.Height = (minimumHeight + 5)
on_MinimumSize = True
End If
If on_MinimumSize Then
stopResizer()
Else
startResizer()
End If
If (Cursor.Position.X > ((Me.Location.X + Me.Width) - borderDiameter)) And (Cursor.Position.Y > (Me.Location.Y + borderSpace)) And (Cursor.Position.Y < ((Me.Location.Y + Me.Height) - borderSpace)) Then
Me.Cursor = Cursors.SizeWE
onBorderRight = True
ElseIf (Cursor.Position.X < (Me.Location.X + borderDiameter)) And (Cursor.Position.Y > (Me.Location.Y + borderSpace)) And (Cursor.Position.Y < ((Me.Location.Y + Me.Height) - borderSpace)) Then
Me.Cursor = Cursors.SizeWE
onBorderLeft = True
ElseIf (Cursor.Position.Y < (Me.Location.Y + borderDiameter)) And (Cursor.Position.X > (Me.Location.X + borderSpace)) And (Cursor.Position.X < ((Me.Location.X + Me.Width) - borderSpace)) Then
Me.Cursor = Cursors.SizeNS
onBorderTop = True
ElseIf (Cursor.Position.Y > ((Me.Location.Y + Me.Height) - borderDiameter)) And (Cursor.Position.X > (Me.Location.X + borderSpace)) And (Cursor.Position.X < ((Me.Location.X + Me.Width) - borderSpace)) Then
Me.Cursor = Cursors.SizeNS
onBorderBottom = True
ElseIf (Cursor.Position.X = ((Me.Location.X + Me.Width) - 1)) And (Cursor.Position.Y = Me.Location.Y) Then
Me.Cursor = Cursors.SizeNESW
onCornerTopRight = True
ElseIf (Cursor.Position.X = Me.Location.X) And (Cursor.Position.Y = Me.Location.Y) Then
Me.Cursor = Cursors.SizeNWSE
onCornerTopLeft = True
ElseIf (Cursor.Position.X = ((Me.Location.X + Me.Width) - 1)) And (Cursor.Position.Y = ((Me.Location.Y + Me.Height) - 1)) Then
Me.Cursor = Cursors.SizeNWSE
onCornerBottomRight = True
ElseIf (Cursor.Position.X = Me.Location.X) And (Cursor.Position.Y = ((Me.Location.Y + Me.Height) - 1)) Then
Me.Cursor = Cursors.SizeNESW
onCornerBottomLeft = True
Else
onBorderRight = False
onBorderLeft = False
onBorderTop = False
onBorderBottom = False
onCornerTopRight = False
onCornerTopLeft = False
onCornerBottomRight = False
onCornerBottomLeft = False
Me.Cursor = Cursors.[Default]
End If
End Sub
Private Sub startResizer()
If movingRight Then
Me.Width = Cursor.Position.X - Me.Location.X
ElseIf movingLeft Then
Me.Width = ((Me.Width + Me.Location.X) - Cursor.Position.X)
Me.Location = New Point(Cursor.Position.X, Me.Location.Y)
ElseIf movingTop Then
Me.Height = ((Me.Height + Me.Location.Y) - Cursor.Position.Y)
Me.Location = New Point(Me.Location.X, Cursor.Position.Y)
ElseIf movingBottom Then
Me.Height = (Cursor.Position.Y - Me.Location.Y)
ElseIf movingCornerTopRight Then
Me.Width = (Cursor.Position.X - Me.Location.X)
Me.Height = ((Me.Location.Y - Cursor.Position.Y) + Me.Height)
Me.Location = New Point(Me.Location.X, Cursor.Position.Y)
ElseIf movingCornerTopLeft Then
Me.Width = ((Me.Width + Me.Location.X) - Cursor.Position.X)
Me.Location = New Point(Cursor.Position.X, Me.Location.Y)
Me.Height = ((Me.Height + Me.Location.Y) - Cursor.Position.Y)
Me.Location = New Point(Me.Location.X, Cursor.Position.Y)
ElseIf movingCornerBottomRight Then
Me.Size = New Size(Cursor.Position.X - Me.Location.X, Cursor.Position.Y - Me.Location.Y)
ElseIf movingCornerBottomLeft Then
Me.Width = ((Me.Width + Me.Location.X) - Cursor.Position.X)
Me.Height = (Cursor.Position.Y - Me.Location.Y)
Me.Location = New Point(Cursor.Position.X, Me.Location.Y)
End If
End Sub
Private Sub stopResizer()
movingRight = False
movingLeft = False
movingTop = False
movingBottom = False
movingCornerTopRight = False
movingCornerTopLeft = False
movingCornerBottomRight = False
movingCornerBottomLeft = False
Me.Cursor = Cursors.[Default]
System.Threading.Thread.Sleep(300)
on_MinimumSize = False
End Sub
End Class