-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShapeButton.ctl
More file actions
3611 lines (3547 loc) · 187 KB
/
ShapeButton.ctl
File metadata and controls
3611 lines (3547 loc) · 187 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
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Begin VB.UserControl ShapeButton
ClientHeight = 3600
ClientLeft = 0
ClientTop = 0
ClientWidth = 4800
ScaleHeight = 3600
ScaleWidth = 4800
ToolboxBitmap = "ShapeButton.ctx":0000
End
Attribute VB_Name = "ShapeButton"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''
' ************************************************* '
' * * '
' ************************************************* '
'''''''''''''''''''''''''''''''''''''''''''''''''''''
'>> Needed For The API Call >> GradientFill >> Backgraound
Private Type GRADIENT_RECT
UpperLeft As Long
LowerRight As Long
End Type
Private Type TRIVERTEX
X As Long
Y As Long
Red As Integer
Green As Integer
Blue As Integer
ALPHA As Integer
End Type
'............................................................
'>>Needed For The API Call >> CreatePolygonRgn >> Polygon
'>>Postion For Picture And Caption ...etc.
Private Type POINTAPI
X As Long
Y As Long
End Type
'............................................................
'>> Constant Types Used With CreatePolygonRgn
Private Const WINDING As Long = 2
'............................................................
'>> Constant Types Used With GradientFill
Private Const GRADIENT_FILL_RECT_H As Long = &H0
Private Const GRADIENT_FILL_RECT_V As Long = &H1
'............................................................
'>> Constant Types For LinsStyle
Private Const BDR_VISUAL As Long = vb3DDKShadow
Private Const BDR_VISUAL1 As Long = vbButtonShadow
Private Const BDR_VISUAL2 As Long = vb3DHighlight
'............................................................
'>> Constant Types For LinsStyle
Private Const BDR_FLAT1 As Long = vb3DDKShadow
Private Const BDR_FLAT2 As Long = vb3DHighlight
'............................................................
'>> Constant Types For LinsStyle
Private Const BDR_JAVA1 As Long = vbButtonShadow
Private Const BDR_JAVA2 As Long = vb3DHighlight
'............................................................
'>> Constant Values For White Border >> IF Mouse Down Button
Private Const BDR_PRESSED As Long = vb3DHighlight
'............................................................
'>> Constant Values For Gold Border >> IF Mouse Over Button
Private Const BDR_GOLDXP_DARK As Long = &H109ADC
Private Const BDR_GOLDXP_NORMAL1 As Long = &H31B2F0
Private Const BDR_GOLDXP_NORMAL2 As Long = &H90D6F7
Private Const BDR_GOLDXP_LIGHT1 As Long = &HCEF3FF
Private Const BDR_GOLDXP_LIGHT2 As Long = &H8CDBFF
'............................................................
'>> Constant Types For LinsStyle
Private Const BDR_VISTA1 As Long = vbWhite
Private Const BDR_VISTA2 As Long = &HCFB073
'............................................................
'>> Constant Types For FocusRect
'>> If Display Properties Colors IS Hight Color(16Bit)Use
'Private Const BDR_FOCUSRECT As Long = &HC0C0C0 '>> Color Gray
'>> If Display Properties Colors IS TrueColor(32Bit)Use
Private Const BDR_FOCUSRECT As Long = &HD1D1D1 '>> Color LightGray
'>> Constant Types For FocusRect Java
Private Const BDR_FOCUSRECT_JAVA As Long = &HCC9999 '>> ColorMauve
'>> Constant Values For FocusRect Vista
Private Const BDR_FOCUSRECT_VISTA As Long = 16698372
'>> Constant Values For FocusRect Xp
Private Const BDR_BLUEXP_DARK As Long = &HD98D59
Private Const BDR_BLUEXP_NORMAL1 As Long = &HE2A981
Private Const BDR_BLUEXP_NORMAL2 As Long = &HF0D1B5
Private Const BDR_BLUEXP_LIGHT1 As Long = &HF7D7BD
Private Const BDR_BLUEXP_LIGHT2 As Long = &HFFE7CE
'............................................................
'>> Constant Types For HandPointer
Private Const CURSOR_HAND = 32649&
'............................................................
'>> API Declare Function's
Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetCapture& Lib "user32" ()
Private Declare Function SetCapture& Lib "user32" (ByVal hWnd&)
Private Declare Function ReleaseCapture& Lib "user32" ()
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As POINTAPI) As Long
Private Declare Function TextOutW Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Function TextOutA Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, lpPoint As POINTAPI) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function Arc Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
Private Declare Function GradientFill Lib "msimg32" (ByVal hdc As Long, ByRef pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As Any, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Integer
Private Declare Function TranslateColor Lib "olepro32.dll" Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, ByVal palet As Long, col As Long) As Long
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function RoundRect Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
'............................................................
'>> Button Declarations
'............................................................
Public Enum EnumButtonShape
Rectangle
RoundedRectangle
'Round
Diamond
Top_Triangle
Left_Triangle
Right_Triangle
Down_Triangle
top_Arrow
Left_Arrow
Right_Arrow
Down_Arrow
End Enum
Public Enum EnumButtonStyle
Custom
Visual
Flat
OverFlat
Java
XPOffice
WinXp
Vista
Glass
End Enum
Public Enum EnumButtonStyleColors
Transparent
SingleColor
Gradient_H
Gradient_V
TubeCenter_H
TubeTopBottom_H
TubeCenter_V
TubeTopBottom_V
End Enum
Public Enum EnumButtonTheme
NoTheme
XpBlue
XpOlive
XPSilver
Visual2005
Norton2005
RedColor
GreenColor
BlueColor
End Enum
Public Enum EnumButtonType
Button
CheckBox
End Enum
Public Enum EnumCaptionAlignment
TopCaption
LeftCaption
CenterCaption
RightCaption
BottomCaption
End Enum
Public Enum EnumCaptionEffect
Default
Raised
Sunken
Outline
End Enum
Public Enum EnumCaptionStyle
Normal
HorizontalFill
VerticalFill
End Enum
Public Enum EnumDropDown
None
LeftDropDown
RightDropDown
End Enum
Public Enum EnumPictureAlignment
TopPicture
LeftPicture
CenterPicture
RightPicture
BottomPicture
End Enum
'............................................................
'>> Property Member Variables
'............................................................
Private mButtonShape As EnumButtonShape
Private mButtonStyle As EnumButtonStyle
Private mButtonStyleColors As EnumButtonStyleColors
Private mButtonTheme As EnumButtonTheme
Private mButtonType As EnumButtonType
Private mCaptionAlignment As EnumCaptionAlignment
Private mCaptionEffect As EnumCaptionEffect
Private mCaptionStyle As EnumCaptionStyle
Private mDropDown As EnumDropDown
Private mPictureAlignment As EnumPictureAlignment
'............................................................
'>> Property Color Variables
Dim mBackColor As OLE_COLOR
Dim mBackColorPressed As OLE_COLOR
Dim mBackColorHover As OLE_COLOR
'............................................................
Dim mBorderColor As OLE_COLOR
Dim mBorderColorPressed As OLE_COLOR
Dim mBorderColorHover As OLE_COLOR
'............................................................
Dim mForeColor As OLE_COLOR
Dim mForeColorPressed As OLE_COLOR
Dim mForeColorHover As OLE_COLOR
'............................................................
Dim mEffectColor As OLE_COLOR
Dim mCaption As String
Dim mFocusRect As Boolean
Dim mFocused As Boolean
Dim mValue As Boolean
Dim mHandPointer As Boolean
Dim mPicture As Picture
Dim mPictureGray As Boolean
'............................................................
Dim CaptionPos(1) As POINTAPI '>> Postion Text
Dim PicturePos(1) As POINTAPI '>> Postion Picture
Dim Fo As POINTAPI '>> Region Of FocusRect
'............................................................
'>> Mouse Button >> Hovered Or Pressed
Private MouseMove, MouseDown As Boolean
Dim P(0 To 7) As POINTAPI
Dim PL(0 To 7) As POINTAPI
Dim Lines As POINTAPI
Dim hRgn As Long
'............................................................
'>> Button Event Declaration's
'............................................................
Public Event Click()
Public Event DblClick()
Public Event KeyDown(KeyCode As Integer, Shift As Integer)
Public Event KeyPress(KeyAscii As Integer)
Public Event KeyUp(KeyCode As Integer, Shift As Integer)
Public Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event OLECompleteDrag(Effect As Long)
Public Event OLEDragDrop(data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event OLEDragOver(data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)
Public Event OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)
Public Event OLESetData(data As DataObject, DataFormat As Integer)
Public Event OLEStartDrag(data As DataObject, AllowedEffects As Long)
'............................................................
'>> Start Properties Button
'............................................................
Public Property Get hdc() As Long
hdc = UserControl.hdc
End Property
Public Property Get hWnd() As Long
hWnd = UserControl.hWnd
End Property
Public Sub Refresh()
UserControl.Refresh
End Sub
Public Property Get ButtonShape() As EnumButtonShape
ButtonShape = mButtonShape
End Property
Public Property Let ButtonShape(ByVal EBS As EnumButtonShape)
mButtonShape = EBS
PropertyChanged "ButtonShape"
UserControl_Paint
End Property
Public Property Get ButtonStyle() As EnumButtonStyle
ButtonStyle = mButtonStyle
End Property
Public Property Let ButtonStyle(ByVal EBS As EnumButtonStyle)
mButtonStyle = EBS
PropertyChanged "ButtonStyle"
'.............................................................
'>> ButtonStyle,Visual, Flat,OverFlat,Java,XpOffice,WinXp
'>> Vista,Glass
'>> Default BackColors To ButtonStyle At Hover,Press,Off
'>> 'Default ForeColors To ButtonStyle At Hover,Press,Off
'.............................................................
Select Case mButtonStyle
Case Is = Visual
mBackColor = vbButtonFace
mBackColorHover = vbButtonFace
mBackColorPressed = vbButtonFace
'mForeColor = vbBlack
'mForeColorHover = vbBlack
'mForeColorPressed = vbBlack
Case Is = Flat
mBackColor = vbButtonFace
mBackColorHover = vbButtonFace
mBackColorPressed = vbButtonFace
'mForeColor = vbBlack
' mForeColorHover = vbBlack
'mForeColorPressed = vbBlack
Case Is = OverFlat
mBackColor = vbButtonFace
mBackColorHover = vbButtonFace
mBackColorPressed = vbButtonFace
'mForeColor = vbBlack
'mForeColorHover = vbBlack
'mForeColorPressed = vbBlack
Case Is = Java
If Not mButtonStyleColors = Transparent Then mButtonStyleColors = SingleColor
mBackColor = vbButtonFace
mBackColorHover = vbButtonFace
mBackColorPressed = &H999999
'mForeColor = vbBlack
'mForeColorHover = vbBlack
'mForeColorPressed = vbBlack
Case Is = XPOffice
mBackColor = vbButtonFace
mBackColorHover = &HB6A59F
mBackColorPressed = &HAF8C80
'mForeColor = vbBlack
'mForeColorHover = vbBlack
'mForeColorPressed = vbBlack
Case Is = WinXp
If Not mButtonStyleColors = Transparent Then mButtonStyleColors = Gradient_V
mBackColor = &HD2DEDD
mBackColorHover = vbWhite
mBackColorPressed = vbWhite
'mForeColor = vbBlack
'mForeColorHover = vbBlack
'mForeColorPressed = vbBlack
Case Is = Vista
mBackColor = &HD8D8D8
mBackColorHover = &HF7DBA5
mBackColorPressed = &HEFCE92
'mForeColor = &H8000000D 'vbhightlight
'mForeColorHover = &H8000000D
'mForeColorPressed = &H8000000D
Case Is = Glass
mBackColor = vbDesktop
mBackColorHover = vbDesktop
mBackColorPressed = vbDesktop
'mForeColor = vbWhite
'mForeColorHover = vbWhite
'mForeColorPressed = vbWhite
End Select
UserControl_Paint
End Property
Public Property Get ButtonStyleColors() As EnumButtonStyleColors
ButtonStyleColors = mButtonStyleColors
End Property
Public Property Let ButtonStyleColors(ByVal EBSC As EnumButtonStyleColors)
mButtonStyleColors = EBSC
PropertyChanged "ButtonStyleColors"
UserControl_Paint
End Property
Public Property Get ButtonTheme() As EnumButtonTheme
ButtonTheme = mButtonTheme
End Property
Public Property Let ButtonTheme(ByVal EBT As EnumButtonTheme)
mButtonTheme = EBT
PropertyChanged "ButtonTheme"
'.............................................................
'>> ButtonTheme,XpBlue,XpOlive,XPSilver,Visual2005,Norton2005
'>> RedColor,GreenColor,BlueColor.
'.............................................................
Select Case mButtonTheme
Case Is = XpBlue
mBackColor = &HF1B39A
mBackColorHover = &HFDF7F4
mBackColorPressed = &HFAE6DD
mBorderColor = &HF1B39A
mBorderColorHover = &HF1B39A
mBorderColorPressed = &HF1B39A
Case Is = XpOlive
mBackColor = &H3DB4A2
mBackColorHover = &HDFF4F2
mBackColorPressed = &HB8E7E0
mBorderColor = &H3DB4A2
mBorderColorHover = &H3DB4A2
mBorderColorPressed = &H3DB4A2
Case Is = XPSilver
mBackColor = &HB5A09D
mBackColorHover = &HF7F5F4
mBackColorPressed = &HECE7E6
mBorderColor = &HB5A09D
mBorderColorHover = mBorderColor
mBorderColorPressed = mBorderColor
Case Is = Visual2005
mBackColor = &HABC2C2
mBackColorHover = &HF2F8F8
mBackColorPressed = &HE6EDEE
mBorderColor = &HABC2C2
mBorderColorHover = mBorderColor
mBorderColorPressed = mBorderColor
Case Is = Norton2005
mBackColor = &H2C5F5
mBackColorHover = &HE2F9FF
mBackColorPressed = &HAFEFFE
mBorderColor = &H2C5F5
mBorderColorHover = mBorderColor
mBorderColorPressed = mBorderColor
Case Is = RedColor
mBackColor = &H26368B
mBackColorHover = &H4763FF
mBackColorPressed = &H425CEE
mBorderColor = vbRed
mBorderColorHover = mBorderColor
mBorderColorPressed = mBorderColor
Case Is = GreenColor
mBackColor = &H578B2E
mBackColorHover = &H9FFF54
mBackColorPressed = &H80CD43
mBorderColor = vbGreen
mBorderColorHover = mBorderColor
mBorderColorPressed = mBorderColor
Case Is = BlueColor
mBackColor = &H8B4027
mBackColorHover = &HFF7648
mBackColorPressed = &HCD5F3A
mBorderColor = vbBlue
mBorderColorHover = mBorderColor
mBorderColorPressed = mBorderColor
End Select
UserControl_Paint
End Property
Public Property Get ButtonType() As EnumButtonType
ButtonType = mButtonType
End Property
Public Property Let ButtonType(ByVal EBT As EnumButtonType)
mButtonType = EBT
PropertyChanged "ButtonType"
UserControl_Paint
End Property
Public Property Get CaptionAlignment() As EnumCaptionAlignment
CaptionAlignment = mCaptionAlignment
End Property
Public Property Let CaptionAlignment(ByVal ECA As EnumCaptionAlignment)
mCaptionAlignment = ECA
PropertyChanged "CaptionAlignment"
UserControl_Paint
End Property
Public Property Get CaptionEffect() As EnumCaptionEffect
CaptionEffect = mCaptionEffect
End Property
Public Property Let CaptionEffect(ByVal ECE As EnumCaptionEffect)
mCaptionEffect = ECE
PropertyChanged "CaptionEffect"
UserControl_Paint
End Property
Public Property Get CaptionStyle() As EnumCaptionStyle
CaptionStyle = mCaptionStyle
End Property
Public Property Let CaptionStyle(ByVal ECS As EnumCaptionStyle)
mCaptionStyle = ECS
PropertyChanged "CaptionStyle"
UserControl_Paint
End Property
Public Property Get DropDown() As EnumDropDown
DropDown = mDropDown
End Property
Public Property Let DropDown(ByVal EDD As EnumDropDown)
mDropDown = EDD
PropertyChanged "DropDown"
UserControl_Paint
End Property
Public Property Get PictureAlignment() As EnumPictureAlignment
PictureAlignment = mPictureAlignment
End Property
Public Property Let PictureAlignment(ByVal EPA As EnumPictureAlignment)
mPictureAlignment = EPA
PropertyChanged "PictureAlignment"
UserControl_Paint
End Property
Public Property Get BackColor() As OLE_COLOR
BackColor = mBackColor
End Property
Public Property Let BackColor(ByVal New_Color As OLE_COLOR)
mBackColor = New_Color
PropertyChanged "BackColor"
UserControl_Paint
End Property
Public Property Get BackColorPressed() As OLE_COLOR
BackColorPressed = mBackColorPressed
End Property
Public Property Let BackColorPressed(ByVal New_Color As OLE_COLOR)
mBackColorPressed = New_Color
PropertyChanged "BackColorPressed"
UserControl_Paint
End Property
Public Property Get BackColorHover() As OLE_COLOR
BackColorHover = mBackColorHover
End Property
Public Property Let BackColorHover(ByVal New_Color As OLE_COLOR)
mBackColorHover = New_Color
PropertyChanged "BackColorHover"
UserControl_Paint
End Property
Public Property Get BorderColor() As OLE_COLOR
BorderColor = mBorderColor
End Property
Public Property Let BorderColor(ByVal New_Color As OLE_COLOR)
mBorderColor = New_Color
PropertyChanged "BorderColor"
UserControl_Paint
End Property
Public Property Get BorderColorPressed() As OLE_COLOR
BorderColorPressed = mBorderColorPressed
End Property
Public Property Let BorderColorPressed(ByVal New_Color As OLE_COLOR)
mBorderColorPressed = New_Color
PropertyChanged "BorderColorPressed"
UserControl_Paint
End Property
Public Property Get BorderColorHover() As OLE_COLOR
BorderColorHover = mBorderColorHover
End Property
Public Property Let BorderColorHover(ByVal New_Color As OLE_COLOR)
mBorderColorHover = New_Color
PropertyChanged "BorderColorHover"
UserControl_Paint
End Property
Public Property Get ForeColor() As OLE_COLOR
ForeColor = mForeColor
End Property
Public Property Let ForeColor(ByVal New_Color As OLE_COLOR)
mForeColor = New_Color
PropertyChanged "ForeColor"
UserControl_Paint
End Property
Public Property Get ForeColorPressed() As OLE_COLOR
ForeColorPressed = mForeColorPressed
End Property
Public Property Let ForeColorPressed(ByVal New_Color As OLE_COLOR)
mForeColorPressed = New_Color
PropertyChanged "ForeColorPressed"
UserControl_Paint
End Property
Public Property Get ForeColorHover() As OLE_COLOR
ForeColorHover = mForeColorHover
End Property
Public Property Let ForeColorHover(ByVal New_Color As OLE_COLOR)
mForeColorHover = New_Color
PropertyChanged "ForeColorHover"
UserControl_Paint
End Property
Public Property Get EffectColor() As OLE_COLOR
EffectColor = mEffectColor
End Property
Public Property Let EffectColor(ByVal New_Color As OLE_COLOR)
mEffectColor = New_Color
PropertyChanged "EffectColor"
UserControl_Paint
End Property
Public Property Get Caption() As String
Caption = mCaption
End Property
Public Property Let Caption(ByVal NewCaption As String)
mCaption = NewCaption
PropertyChanged "Caption"
UserControl_Paint
End Property
Public Property Get FocusRect() As Boolean
FocusRect = mFocusRect
End Property
Public Property Let FocusRect(ByVal New_FocusRect As Boolean)
mFocusRect = New_FocusRect
PropertyChanged "FocusRect"
UserControl_Paint
End Property
Public Property Get value() As Boolean
value = mValue
End Property
Public Property Let value(ByVal New_Value As Boolean)
mValue = New_Value
PropertyChanged "Value"
UserControl_Paint
End Property
Public Property Get HandPointer() As Boolean
HandPointer = mHandPointer
End Property
Public Property Let HandPointer(ByVal New_HandPointer As Boolean)
mHandPointer = New_HandPointer
PropertyChanged "HandPointer"
UserControl_Paint
End Property
Public Property Get Picture() As Picture
Set Picture = mPicture
End Property
Public Property Set Picture(ByVal New_Picture As Picture)
Set mPicture = New_Picture
PropertyChanged "Picture"
UserControl_Paint
End Property
Public Property Get PictureGray() As Boolean
PictureGray = mPictureGray
End Property
Public Property Let PictureGray(ByVal New_PictureGray As Boolean)
mPictureGray = New_PictureGray
PropertyChanged "PictureGray"
UserControl_Paint
End Property
'............................................................
'............................................................
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_Paint
End Property
Public Property Get Font() As Font
Set Font = UserControl.Font
End Property
Public Property Set Font(ByVal New_Font As Font)
Set UserControl.Font = New_Font
PropertyChanged "Font"
UserControl_Paint
End Property
Public Property Get MousePointer() As MousePointerConstants
MousePointer = UserControl.MousePointer
End Property
Public Property Let MousePointer(ByVal New_MousePointer As MousePointerConstants)
UserControl.MousePointer() = New_MousePointer
PropertyChanged "MousePointer"
UserControl_Paint
End Property
Public Property Get MouseIcon() As Picture
Set MouseIcon = UserControl.MouseIcon
End Property
Public Property Set MouseIcon(ByVal New_MouseIcon As Picture)
Set UserControl.MouseIcon() = New_MouseIcon
PropertyChanged "MouseIcon"
UserControl_Paint
End Property
'............................................................
'>> End Properties
'............................................................
'............................................................
'>> Convert Color's >> Red,Green,Blue To VB Color's
'............................................................
Private Sub ConvertRGB(ByVal Color As Long, R, G, b As Long)
TranslateColor Color, 0, Color
R = Color And vbRed
G = (Color And vbGreen) / 256
b = (Color And vbBlue) / 65536
End Sub
'............................................................
'>> Start UserControl
'............................................................
Private Sub UserControl_Click()
'>> Start The Button Pressed
If Me.ButtonType = CheckBox Then mValue = MouseDown = False
UserControl_Paint
RaiseEvent Click
End Sub
Private Sub UserControl_DblClick()
'>> Start The Button Pressed Too
MouseDown = True
UserControl_Paint
RaiseEvent DblClick
End Sub
Private Sub UserControl_GotFocus()
'>> Show FocusRect If Click Button
mFocused = True
UserControl_Paint
End Sub
Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 Or KeyCode = 13 Then '>> Space Or '>> Enter
MouseDown = True
UserControl_Paint
End If
RaiseEvent KeyDown(KeyCode, Shift)
End Sub
Private Sub UserControl_KeyPress(KeyAscii As Integer)
RaiseEvent KeyPress(KeyAscii)
End Sub
Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
If MouseDown = True Then
MouseDown = False
UserControl_Paint
'>> Return Button To Original Shape If ButtonType >> CheckBox
If KeyCode = vbKeyReturn Then UserControl_MouseDown 0, 0, 0, 0
End If
RaiseEvent KeyUp(KeyCode, Shift)
End Sub
Private Sub UserControl_LostFocus()
'>> Visible FocusRect If Clicked Another Button
mFocused = False
UserControl_Paint
End Sub
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'>> Start The Button Pressed
MouseDown = True
UserControl_Paint
RaiseEvent MouseDown(Button, Shift, X, Y)
End Sub
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim pt As POINTAPI
Dim Hovered As Boolean '>> False Or Ture
With UserControl
GetCursorPos pt
ScreenToClient .hWnd, pt
'>> We Don't Need To Check Postion Mouse
If Not UserControl.Ambient.UserMode Then Exit Sub
' See If The Mouse Is Over The Control
If (pt.X < 0) Or (pt.Y < 0) Or (pt.X > .ScaleWidth) Or (pt.Y > .ScaleHeight) Then
Hovered = False '>> Mouse Is Leave Of Button
ReleaseCapture
Else
Hovered = True '>> Mouse Over Button
SetCapture .hWnd
End If
' Redraw The Control If Necessary
If MouseMove <> Hovered Then
MouseMove = Hovered
MouseDown = False
UserControl_Paint
End If
End With
RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub
Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If GetCapture() <> UserControl.hWnd Then SetCapture UserControl.hWnd
Dim Pressed As Boolean
' Raise The Click Event If The Button Is Currently Pressed
If Pressed Then RaiseEvent Click
Pressed = MouseDown
' Stop The Button Pressed
MouseDown = False
UserControl_Paint
RaiseEvent MouseUp(Button, Shift, X, Y)
End Sub
Private Sub UserControl_InitProperties()
'On Local Error Resume Next
UserControl.Width = 1200
UserControl.Height = 500
mButtonShape = Rectangle
mButtonStyle = Visual
mButtonStyleColors = SingleColor
mButtonTheme = NoTheme
mButtonType = Button
mCaptionAlignment = CenterCaption
mCaptionStyle = Normal
mCaptionEffect = Default
mDropDown = None
mPictureAlignment = CenterPicture
mBackColor = vbButtonFace
mBackColorPressed = vbButtonFace
mBackColorHover = vbButtonFace
'mBorderColor = vbBlack
'mBorderColorHover = vbBlack
'mBorderColorPressed = vbBlack
mForeColor = vbBlack
mForeColorPressed = vbRed
mForeColorHover = vbBlue
mEffectColor = vbWhite
mCaption = Ambient.DisplayName
mFocusRect = True
mValue = False
mHandPointer = False
Set mPicture = Nothing
mPictureGray = False
UserControl.Enabled = True
UserControl.Font = "Tahoma"
UserControl_Paint
End Sub
Private Sub UserControl_OLECompleteDrag(Effect As Long)
RaiseEvent OLECompleteDrag(Effect)
End Sub
Private Sub UserControl_OLEDragDrop(data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent OLEDragDrop(data, Effect, Button, Shift, X, Y)
End Sub
Private Sub UserControl_OLEDragOver(data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)
RaiseEvent OLEDragOver(data, Effect, Button, Shift, X, Y, State)
End Sub
Private Sub UserControl_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)
RaiseEvent OLEGiveFeedback(Effect, DefaultCursors)
End Sub
Private Sub UserControl_OLESetData(data As DataObject, DataFormat As Integer)
RaiseEvent OLESetData(data, DataFormat)
End Sub
Private Sub UserControl_OLEStartDrag(data As DataObject, AllowedEffects As Long)
RaiseEvent OLEStartDrag(data, AllowedEffects)
End Sub
Private Sub UserControl_Paint()
'On Local Error Resume Next
With UserControl
.AutoRedraw = True
.ScaleMode = 3
.Cls
'............................................................
'>> Width = Height To Nice Show Border's.
'............................................................
If .Width < 375 Then .Width = 375
If .Height < 375 Then .Height = 375
If Not mButtonShape = Rectangle Then
If Not mButtonShape = RoundedRectangle Then
If .Width > .Height Then .Height = .Width Else .Height = .Width
End If
End If
'............................................................
'>> Change MousePointer To HandCursor
'............................................................
If MouseDown Then
If mFocused And mHandPointer Then SetCursor LoadCursor(0, CURSOR_HAND)
ElseIf MouseMove Then
If mHandPointer Then SetCursor LoadCursor(0, CURSOR_HAND)
Else
If mFocused And mHandPointer Then SetCursor LoadCursor(0, CURSOR_HAND)
End If
'............................................................
'>> Use Value For Viwe CheckBox(ButtonPressed) At TimeShow
'............................................................
Select Case mButtonType
Case Is = CheckBox
If mValue Then MouseDown = True
End Select
'............................................................
'>> Change BackColor When Mouse Hovered Or Pressed Or Off
'............................................................
Dim BkRed(0 To 1), BkGreen(0 To 1), BkBlue(0 To 1) As Long
Dim vert(1) As TRIVERTEX, GRect As GRADIENT_RECT
If MouseDown Then
ConvertRGB mBackColor, BkRed(0), BkGreen(0), BkBlue(0)
ConvertRGB mBackColorPressed, BkRed(1), BkGreen(1), BkBlue(1)
ElseIf MouseMove Then
ConvertRGB mBackColor, BkRed(0), BkGreen(0), BkBlue(0)
ConvertRGB mBackColorHover, BkRed(1), BkGreen(1), BkBlue(1)
Else
ConvertRGB mBackColor, BkRed(0), BkGreen(0), BkBlue(0)
ConvertRGB mBackColorPressed, BkRed(1), BkGreen(1), BkBlue(1)
End If
vert(0).Red = Val("&H" & Hex(BkRed(0)) & "00"): vert(0).Green = Val("&H" & Hex(BkGreen(0)) & "00"): vert(0).Blue = Val("&H" & Hex(BkBlue(0)) & "00"): vert(0).ALPHA = 0&
vert(1).Red = Val("&H" & Hex(BkRed(1)) & "00"): vert(1).Green = Val("&H" & Hex(BkGreen(1)) & "00"): vert(1).Blue = Val("&H" & Hex(BkBlue(1)) & "00"): vert(1).ALPHA = 0&
GRect.UpperLeft = 1: GRect.LowerRight = 0
'............................................................
'>> ButtonStyleColors,Transparent,SingleColour
'>> GradientHorizontalFill,VerticalGradientFill
'>> SwapHorizontalFill,SwapVerticalFill,GradientTubeCenter_H
'>> ,GradientTubeTopBottom_H,GradientTubeCenter_V
'>> GradientTubeTopBottom_V
'............................................................
Select Case mButtonStyleColors
Case Is = Transparent
.BackStyle = 0
Case Is = SingleColor
.BackStyle = 1
If MouseDown Then
.BackColor = mBackColorPressed
Else
If MouseMove Then
.BackColor = mBackColorHover
Else
.BackColor = mBackColor
End If
End If
Case Is = Gradient_H
.BackStyle = 1
vert(0).X = 0: vert(0).Y = .ScaleHeight
vert(1).X = .ScaleWidth: vert(1).Y = 0
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_H
Case Is = Gradient_V
.BackStyle = 1
vert(0).X = 0: vert(0).Y = .ScaleHeight
vert(1).X = .ScaleWidth: vert(1).Y = 0
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_V
Case Is = TubeCenter_H
.BackStyle = 1
vert(0).X = .ScaleWidth: vert(0).Y = 0
vert(1).X = 0: vert(1).Y = .ScaleHeight / 2
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_V
vert(0).X = 0: vert(0).Y = .ScaleHeight
vert(1).X = .ScaleWidth: vert(1).Y = .ScaleHeight / 2
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_V
Case Is = TubeTopBottom_H
.BackStyle = 1
vert(0).X = 0: vert(0).Y = .ScaleHeight / 2
vert(1).X = .ScaleWidth: vert(1).Y = 0
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_V
vert(0).X = 0: vert(0).Y = .ScaleHeight / 2
vert(1).X = .ScaleWidth: vert(1).Y = .ScaleHeight
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_V
Case Is = TubeCenter_V
.BackStyle = 1
vert(0).X = 0: vert(0).Y = 0
vert(1).X = .ScaleWidth / 2: vert(1).Y = .ScaleHeight
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_H
vert(0).X = .ScaleWidth: vert(0).Y = .ScaleHeight
vert(1).X = .ScaleWidth / 2: vert(1).Y = 0
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_H
Case Is = TubeTopBottom_V
.BackStyle = 1
vert(0).X = .ScaleWidth / 2: vert(0).Y = 0
vert(1).X = 0: vert(1).Y = .ScaleHeight
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_H
vert(0).X = .ScaleWidth / 2: vert(0).Y = .ScaleHeight
vert(1).X = .ScaleWidth: vert(1).Y = 0
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_H
End Select
'.............................................................
'>> ButtonStyle,Visual, Flat,OverFlat,Java,XpOffice,WinXp
'>> Vista,Glass
'>> Set BorderColors To ButtonStyle At Hover,Press,Off
'.............................................................
Select Case mButtonStyle
Case Is = Visual
mBorderColor = vb3DDKShadow
mBorderColorHover = vb3DDKShadow
mBorderColorPressed = vb3DHighlight
Case Is = Flat
mBorderColor = vb3DDKShadow
mBorderColorHover = vb3DDKShadow
mBorderColorPressed = vb3DHighlight
Case Is = OverFlat
mBorderColor = mBackColor '>> Visible BorderColor At RunTime
mBorderColorHover = vb3DDKShadow
mBorderColorPressed = vb3DHighlight
Case Is = Java
mBorderColor = vbButtonShadow
mBorderColorHover = vbButtonShadow
mBorderColorPressed = vbButtonShadow
Case Is = XPOffice
mBorderColor = vbButtonFace
mBorderColorHover = vbBlack
mBorderColorPressed = vbBlack
'............................................................
'>> Change BackColor XpOffice When Mouse Hovered,Pressed,Off
'............................................................
If Not mButtonStyleColors = Transparent Then
If MouseDown Then
ConvertRGB &HA57F71, BkRed(0), BkGreen(0), BkBlue(0)
ConvertRGB mBackColorPressed, BkRed(1), BkGreen(1), BkBlue(1)
ElseIf MouseMove Then
ConvertRGB &HAC9891, BkRed(0), BkGreen(0), BkBlue(0)
ConvertRGB mBackColorHover, BkRed(1), BkGreen(1), BkBlue(1)
Else
ConvertRGB mBackColor, BkRed(0), BkGreen(0), BkBlue(0)
ConvertRGB mBackColor, BkRed(1), BkGreen(1), BkBlue(1)
End If
vert(0).Red = Val("&H" & Hex(BkRed(0)) & "00"): vert(0).Green = Val("&H" & Hex(BkGreen(0)) & "00"): vert(0).Blue = Val("&H" & Hex(BkBlue(0)) & "00"): vert(0).ALPHA = 0&
vert(1).Red = Val("&H" & Hex(BkRed(1)) & "00"): vert(1).Green = Val("&H" & Hex(BkGreen(1)) & "00"): vert(1).Blue = Val("&H" & Hex(BkBlue(1)) & "00"): vert(1).ALPHA = 0&
GRect.UpperLeft = 1: GRect.LowerRight = 0
vert(0).X = 0: vert(0).Y = .ScaleHeight
vert(1).X = .ScaleWidth: vert(1).Y = 0
GradientFill .hdc, vert(0), 2, GRect, 1, GRADIENT_FILL_RECT_V
End If
Case Is = WinXp
mBorderColor = vbBlack
mBorderColorHover = vbBlack
mBorderColorPressed = vbBlack
'............................................................
'>> Change BackColor WinXp When Mouse Hovered,Pressed,Off
'............................................................
If Not mButtonStyleColors = Transparent Then
If MouseDown Then
ConvertRGB mBackColor, BkRed(0), BkGreen(0), BkBlue(0)
ConvertRGB &HE0E6E6, BkRed(1), BkGreen(1), BkBlue(1)
ElseIf .Enabled Then
ConvertRGB mBackColor, BkRed(0), BkGreen(0), BkBlue(0)
ConvertRGB Me.BackColorPressed, BkRed(1), BkGreen(1), BkBlue(1)
Else