-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDarkCheckBox.ctl
327 lines (291 loc) · 10.2 KB
/
DarkCheckBox.ctl
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
VERSION 5.00
Begin VB.UserControl DarkCheckBox
BackColor = &H00302D2D&
ClientHeight = 375
ClientLeft = 0
ClientTop = 0
ClientWidth = 1980
ScaleHeight = 375
ScaleWidth = 1980
ToolboxBitmap = "DarkCheckBox.ctx":0000
Begin VB.Timer tmrSetImage
Enabled = 0 'False
Interval = 10
Left = 1440
Top = 360
End
Begin VB.Label labTip
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Dark¡áCheckBox"
BeginProperty Font
Name = "Microsoft YaHei UI"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 225
Left = 480
TabIndex = 0
Top = 120
Width = 1410
End
Begin VB.Image imgYesMouseIn
Height = 225
Left = 600
Picture = "DarkCheckBox.ctx":0312
Top = 1200
Visible = 0 'False
Width = 225
End
Begin VB.Image imgYesMouseDown
Height = 225
Left = 1080
Picture = "DarkCheckBox.ctx":0668
Top = 1200
Visible = 0 'False
Width = 225
End
Begin VB.Image imgYesNormal
Height = 225
Left = 120
Picture = "DarkCheckBox.ctx":09BE
Top = 1200
Visible = 0 'False
Width = 225
End
Begin VB.Image imgNoMouseDown
Height = 225
Left = 1080
Picture = "DarkCheckBox.ctx":0D14
Top = 720
Visible = 0 'False
Width = 225
End
Begin VB.Image imgNoMouseIn
Height = 225
Left = 600
Picture = "DarkCheckBox.ctx":106A
Top = 720
Visible = 0 'False
Width = 225
End
Begin VB.Image imgNoNormal
Height = 225
Left = 120
Picture = "DarkCheckBox.ctx":13C0
Top = 720
Visible = 0 'False
Width = 225
End
Begin VB.Image imgState
Enabled = 0 'False
Height = 225
Left = 120
Picture = "DarkCheckBox.ctx":1716
Top = 120
Width = 225
End
End
Attribute VB_Name = "DarkCheckBox"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Dark¡áCheckBox by IceLolly
'Date: 2018.8.6
Private Const SZ_DISTANCE = 60
Dim bDown As Boolean
Dim bFocused As Boolean
'Default Property Values:
Const m_def_Enabled = 0
Const m_def_Value = 0
'Property Variables:
Dim m_Value As Boolean
'Event Declarations:
Event Click()
Attribute Click.VB_Description = "Occurs when the user presses and then releases a mouse button over an object."
Private Sub labTip_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call UserControl_MouseDown(Button, 0, 0, 0)
End Sub
Private Sub labTip_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
UserControl.labTip.ToolTipText = Extender.ToolTipText
Call UserControl_MouseMove(0, 0, 0, 0)
End Sub
Private Sub labTip_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call UserControl_MouseUp(Button, 0, 0, 0)
End Sub
Private Sub tmrSetImage_Timer()
Dim pt As POINT
Dim Target As Long
GetCursorPos pt
Target = WindowFromPoint(pt.X, pt.Y)
If Target <> UserControl.hWnd Then
If Me.Value Then
UserControl.imgState.Picture = UserControl.imgYesNormal.Picture
Else
UserControl.imgState.Picture = UserControl.imgNoNormal.Picture
End If
UserControl.tmrSetImage.Enabled = False
End If
End Sub
Private Sub UserControl_Initialize()
Call UserControl_Resize
End Sub
Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Or KeyCode = vbKeyReturn Then
Call UserControl_MouseDown(1, 0, 0, 0)
End If
End Sub
Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Or KeyCode = vbKeyReturn Then
Value = Not Value
bDown = False
RaiseEvent Click
End If
End Sub
Private Sub UserControl_LostFocus()
bFocused = False
If Me.Value Then
UserControl.imgState.Picture = UserControl.imgYesNormal.Picture
Else
UserControl.imgState.Picture = UserControl.imgNoNormal.Picture
End If
End Sub
Private Sub UserControl_GotFocus()
bFocused = True
bDown = False
If Me.Value = True Then
UserControl.imgState.Picture = UserControl.imgYesMouseIn.Picture
Else
UserControl.imgState.Picture = UserControl.imgNoMouseIn.Picture
End If
End Sub
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
bDown = True
If Me.Value Then
UserControl.imgState.Picture = UserControl.imgYesMouseDown.Picture
Else
UserControl.imgState.Picture = UserControl.imgNoMouseDown.Picture
End If
End If
End Sub
Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
bDown = False
If Button = vbLeftButton Then
Dim pt As POINT
Dim Target As Long
GetCursorPos pt
Target = WindowFromPoint(pt.X, pt.Y)
If Target = UserControl.hWnd Then
Value = Not Value
RaiseEvent Click
End If
End If
End Sub
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not bDown Then
If Me.Value = True Then
UserControl.imgState.Picture = UserControl.imgYesMouseIn.Picture
Else
UserControl.imgState.Picture = UserControl.imgNoMouseIn.Picture
End If
Else
If Me.Value = True Then
UserControl.imgState.Picture = UserControl.imgYesMouseDown.Picture
Else
UserControl.imgState.Picture = UserControl.imgNoMouseDown.Picture
End If
End If
UserControl.tmrSetImage.Enabled = True
End Sub
Private Sub UserControl_Resize()
On Error Resume Next
UserControl.imgState.Left = SZ_DISTANCE
UserControl.imgState.Top = UserControl.Height / 2 - UserControl.imgState.Height / 2
UserControl.labTip.Top = UserControl.Height / 2 - UserControl.labTip.Height / 2
UserControl.labTip.Left = UserControl.imgState.Left + UserControl.imgState.Width + SZ_DISTANCE
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
UserControl.Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled)
Set labTip.Font = PropBag.ReadProperty("Font", Ambient.Font)
labTip.Caption = PropBag.ReadProperty("Caption", "Dark¡áCheckBox")
m_Value = PropBag.ReadProperty("Value", m_def_Value)
Call UserControl_Resize
UserControl.labTip.Enabled = UserControl.Enabled
If Me.Value Then
UserControl.imgState.Picture = UserControl.imgYesNormal.Picture
Else
UserControl.imgState.Picture = UserControl.imgNoNormal.Picture
End If
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Enabled", UserControl.Enabled, m_def_Enabled)
Call PropBag.WriteProperty("Font", labTip.Font, Ambient.Font)
Call PropBag.WriteProperty("Caption", labTip.Caption, "Dark¡áCheckBox")
Call PropBag.WriteProperty("Value", m_Value, m_def_Value)
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=0,0,0,0
Public Property Get Enabled() As Boolean
Enabled = UserControl.Enabled
End Property
Public Property Let Enabled(ByVal New_Enabled As Boolean)
UserControl.Enabled = New_Enabled
PropertyChanged "Enabled"
UserControl.labTip.Enabled = New_Enabled
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=labTip,labTip,-1,Font
Public Property Get Font() As Font
Set Font = labTip.Font
End Property
Public Property Set Font(ByVal New_Font As Font)
Set labTip.Font = New_Font
PropertyChanged "Font"
Call UserControl_Resize
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=labTip,labTip,-1,Caption
Public Property Get Caption() As String
Caption = labTip.Caption
End Property
Public Property Let Caption(ByVal New_Caption As String)
labTip.Caption() = New_Caption
PropertyChanged "Caption"
Call UserControl_Resize
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=0,0,0,0
Public Property Get Value() As Boolean
Value = m_Value
End Property
Public Property Let Value(ByVal New_Value As Boolean)
m_Value = New_Value
PropertyChanged "Value"
If Not bFocused Then
If New_Value Then
UserControl.imgState.Picture = UserControl.imgYesNormal.Picture
Else
UserControl.imgState.Picture = UserControl.imgNoNormal.Picture
End If
Else
If New_Value Then
UserControl.imgState.Picture = UserControl.imgYesMouseIn.Picture
Else
UserControl.imgState.Picture = UserControl.imgNoMouseIn.Picture
End If
End If
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
m_Value = m_def_Value
End Sub