-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCtlUltraPGBar.ctl
More file actions
1128 lines (863 loc) · 39.2 KB
/
Copy pathCtlUltraPGBar.ctl
File metadata and controls
1128 lines (863 loc) · 39.2 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 ucProgressBar
ClientHeight = 990
ClientLeft = 0
ClientTop = 0
ClientWidth = 3000
ScaleHeight = 990
ScaleWidth = 3000
ToolboxBitmap = "CtlUltraPGBar.ctx":0000
End
Attribute VB_Name = "ucProgressBar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'-----------------------------------------------------------
'Mario Flores Cool Xp ProgressBar
'Emulating The Windows XP Progress Bar
'Open Source
'6 May 2004
'-----------------------------------------------------------
'Mario Flores Cool Xp ProgressBar 2.0
'MultiStyle ProgressBar
'Open Source
'September 12 2004
'-----------------------------------------------------------
'CD JUAREZ CHIHUAHUA MEXICO
Option Explicit
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Any) As Long
Private Declare Function CreateHatchBrush Lib "gdi32" (ByVal fnStyle As Integer, ByVal COLORREF As Long) As Long
Private Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function FrameRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) 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 MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, lpPoint As POINTAPI) As Long
Private Declare Function PatBlt Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
'=====================================================
'TEXT FORMAT CONST
Const DT_SINGLELINE As Long = &H20
Const DT_CALCRECT As Long = &H400
'=====================================================
'=====================================================
'BORDER FIELD CONST
Const BF_BOTTOM = &H8
Const BF_LEFT = &H1
Const BF_RIGHT = &H4
Const BF_TOP = &H2
Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
'=====================================================
'=====================================================
'THE POINTAPI STRUCTURE
Private Type POINTAPI
X As Long ' The POINTAPI structure defines the x- and y-coordinates of a point.
Y As Long
End Type
'=====================================================
'=====================================================
'THE RECT STRUCTURE
Private Type RECT
Left As Long 'The RECT structure defines the coordinates of the upper-left and lower-right corners of a rectangle
Top As Long
Right As Long
Bottom As Long
End Type
'=====================================================
'=====================================================
'THE BRUSHSTYLE ENUM
Public Enum BrushStyle
HS_HORIZONTAL = 0
HS_VERTICAL = 1
HS_FDIAGONAL = 2
HS_BDIAGONAL = 3
HS_CROSS = 4
HS_DIAGCROSS = 5
HS_SOLID = 6
End Enum
'=====================================================
'=====================================================
'THE COOL XP PROGRESSBAR 2.0 STYLES
Public Enum cScrolling
ccScrollingStandard = 0
ccScrollingSmooth = 1
ccScrollingSearch = 2
ccScrollingOfficeXP = 3
ccScrollingPastel = 4
ccScrollingJavT = 5
ccScrollingMediaPlayer = 6
ccScrollingCustomBrush = 7
ccScrollingPicture = 8
ccScrollingMetallic = 9
End Enum
'=====================================================
'=====================================================
'THE ORIENTATION ENUM
Public Enum cOrientation
ccOrientationHorizontal = 0
ccOrientationVertical = 1
End Enum
'=====================================================
'----------------------------------------------------
Private m_Color As OLE_COLOR
Private m_hDC As Long
Private m_hWnd As Long 'PROPERTIES VARIABLES
Private m_Max As Long
Private m_Min As Long
Private m_Value As Long
Private m_ShowText As Boolean
Private m_Scrolling As cScrolling
Private m_Orientation As cOrientation
Private m_Brush As BrushStyle
Private m_Picture As StdPicture
'----------------------------------------------------
'----------------------------------------------------
Private m_MemDC As Boolean
Private m_ThDC As Long
Private m_hBmp As Long
Private m_hBmpOld As Long
Private iFnt As IFont
Private m_fnt As IFont 'VARIABLES USED IN PROCESS
Private hFntOld As Long
Private m_lWidth As Long
Private m_lHeight As Long
Private fPercent As Double
Private TR As RECT
Private TBR As RECT
Private TSR As RECT
Private AT As RECT
Private lSegmentWidth As Long
Private lSegmentSpacing As Long
'----------------------------------------------------
'==========================================================
'/---Draw ALL ProgressXP Bar !!!!PUBLIC CALL!!!
'==========================================================
Public Sub DrawProgressBar()
If m_Value > 100 Then m_Value = 100
GetClientRect m_hWnd, TR '//--- Reference = Control Client Area
DrawFillRectangle TR, IIf(m_Scrolling = ccScrollingMediaPlayer, &H0, vbWhite), m_hDC '//--- Draw BackGround
'//-- Draw ProgressBar Style
'==========================================================
'/---Draw METALLIC XP STYLE
'==========================================================
If m_Scrolling = ccScrollingMetallic Then
DrawMetalProgressbar
'==========================================================
'/---Draw OFFICE XP STYLE
'==========================================================
ElseIf m_Scrolling = ccScrollingOfficeXP Then
DrawOfficeXPProgressbar
'==========================================================
'/---Draw PASTEL XP STYLE
'==========================================================
ElseIf m_Scrolling = ccScrollingPastel Then
DrawPastelProgressbar
'==========================================================
'/---Draw JAVT XP STYLE
'==========================================================
ElseIf m_Scrolling = ccScrollingJavT Then
DrawJavTProgressbar
'==========================================================
'/---Draw MEDIA PLAYER XP STYLE
'==========================================================
ElseIf m_Scrolling = ccScrollingMediaPlayer Then
DrawMediaProgressbar
'==========================================================
'/---Draw CUSTOM BRUSH XP WASH COLOR STYLE
'==========================================================
ElseIf m_Scrolling = ccScrollingCustomBrush Then
DrawCustomBrushProgressbar
'==========================================================
'/---Draw PICTURE STYLE
'==========================================================
ElseIf m_Scrolling = ccScrollingPicture Then
DrawPictureProgressbar
Else
'==========================================================
'/---Draw WINDOWS XP STYLE
'==========================================================
CalcBarSize '//--- Calculate Progress and Percent Values
PBarDraw '//--- Draw Scolling Bar (Inside Bar)
If m_Scrolling = 0 Then DrawDivisions '//--- Draw SegmentSpacing (This Will Generate the Blocks Effect)
pDrawBorder '//--- Draw The XP Look Border
End If
'==========================================================
DrawTexto '//--- Draw The Percent Text
'==========================================================
'/---Use the AntiFlicker DC
'==========================================================
If m_MemDC Then
With UserControl
pDraw .hdc, 0, 0, .ScaleWidth, .ScaleHeight, .ScaleLeft, .ScaleTop
End With
End If
End Sub
'==========================================================
'/---OFFICE XP STYLE
'==========================================================
Private Sub DrawOfficeXPProgressbar()
DrawRectangle TR, ShiftColorXP(m_Color, 100), m_hDC
With TBR
.Left = 1
.Top = 1
.Bottom = TR.Bottom - 1
.Right = TR.Left + (TR.Right - TR.Left) * (m_Value / 100)
End With
DrawFillRectangle TBR, ShiftColorXP(m_Color, 180), m_hDC
End Sub
'==========================================================
'/---JAVT XP STYLE
'==========================================================
Private Sub DrawJavTProgressbar()
DrawRectangle TR, ShiftColorXP(m_Color, 10), m_hDC
TBR.Right = TR.Left + (TR.Right - TR.Left) * (m_Value / 101)
DrawGradient m_Color, ShiftColorXP(m_Color, 100), 2, 2, TR.Right - 2, TR.Bottom - 5, m_hDC ', True
DrawGradient ShiftColorXP(m_Color, 250), m_Color, 3, 3, TBR.Right, TR.Bottom - 6, m_hDC ', True
DrawLine TBR.Right, 2, TBR.Right, TR.Bottom - 2, m_hDC, ShiftColorXP(m_Color, 25)
End Sub
'==========================================================
'/---PICTURE STYLE
'==========================================================
Private Sub DrawPictureProgressbar()
Dim Brush As Long
Dim origBrush As Long
DrawEdge m_hDC, TR, 2, BF_RECT '//--- Draw ProgressBar Border
If Nothing Is m_Picture Then Exit Sub '//--- In Case No Picture is Choosen
Brush = CreatePatternBrush(m_Picture.Handle) '//-- Use Pattern Picture Draw
origBrush = SelectObject(m_hDC, Brush)
TBR.Right = TR.Left + (TR.Right - TR.Left) * (m_Value / 101)
PatBlt m_hDC, 2, 2, TBR.Right, TR.Bottom - 4, vbPatCopy
SelectObject m_hDC, origBrush
DeleteObject Brush
End Sub
'==========================================================
'/---PASTEL XP STYLE
'==========================================================
Private Sub DrawPastelProgressbar()
DrawEdge m_hDC, TR, 6, BF_RECT
DrawGradient ShiftColorXP(m_Color, 140), ShiftColorXP(m_Color, 200), 2, 2, TR.Left + (TR.Right - TR.Left - 4) * (m_Value / 100), TR.Bottom - 3, m_hDC, True
End Sub
'==========================================================
'/---METALLIC XP STYLE
'==========================================================
Private Sub DrawMetalProgressbar()
TBR.Right = TR.Left + (TR.Right - TR.Left - 4) * (m_Value / 100)
DrawGradient vbWhite, &HC0C0C0, 2, 2, TR.Right - 3, (TR.Bottom - 3) / 2, m_hDC
DrawGradient BlendColor(&HC0C0C0, &H0, 255), &HC0C0C0, 2, (TR.Bottom - 3) / 2, TR.Right - 3, (TR.Bottom - 3) / 2, m_hDC
DrawGradient ShiftColorXP(m_Color, 150), BlendColor(m_Color, &H0, 180), 2, 2, TBR.Right, (TR.Bottom - 3) / 2, m_hDC
DrawGradient BlendColor(m_Color, &H0, 190), m_Color, 2, (TR.Bottom - 3) / 2, TBR.Right, (TR.Bottom - 3) / 2, m_hDC
TR.Left = TR.Left + 3
pDrawBorder
End Sub
'==========================================================
'/---CUSTOM BRUSH XP STYLE
'==========================================================
Private Sub DrawCustomBrushProgressbar()
Dim hBrush As Long
DrawEdge m_hDC, TR, 9, BF_RECT
With TBR
.Left = 2
.Top = 2
.Bottom = TR.Bottom - 2
.Right = TR.Left + (TR.Right - TR.Left) * (m_Value / 101)
End With
hBrush = CreateHatchBrush(m_Brush, GetLngColor(Color))
SetBkColor m_hDC, ShiftColorXP(m_Color, 140)
FillRect m_hDC, TBR, hBrush
DeleteObject hBrush
End Sub
'==========================================================
'/---MEDIA PROGRESS XP STYLE
'==========================================================
Private Sub DrawMediaProgressbar()
DrawRectangle TR, BlendColor(m_Color, &H0, 200), m_hDC
DrawGradient &H0&, ShiftColorXP(GetLngColor(BlendColor(m_Color, &H0, 100)), 10), 2, 2, TR.Left + (TR.Right - TR.Left - 5) * (m_Value / 100), TR.Bottom - 2, m_hDC, True
End Sub
'==========================================================
'/---Calculate Division Bars & Percent Values
'==========================================================
Private Sub CalcBarSize()
lSegmentWidth = IIf(m_Scrolling = 0, 6, 0) '/-- Windows Default
lSegmentSpacing = 2 '/-- Windows Default
TR.Left = TR.Left + 3
LSet TBR = TR
fPercent = m_Value / 98
If fPercent < 0# Then fPercent = 0#
If m_Orientation = 0 Then
'=======================================================================================
' Calc Horizontal ProgressBar
'---------------------------------------------------------------------------------------
TBR.Right = TR.Left + (TR.Right - TR.Left) * fPercent
TBR.Right = TBR.Right - ((TBR.Right - TBR.Left) Mod (lSegmentWidth + lSegmentSpacing))
If TBR.Right < TR.Left Then
TBR.Right = TR.Left
End If
Else
'=======================================================================================
' Calc Vertical ProgressBar
'---------------------------------------------------------------------------------------
fPercent = 1# - fPercent
TBR.Top = TR.Top + (TR.Bottom - TR.Top) * fPercent
TBR.Top = TBR.Top - ((TBR.Top - TBR.Bottom) Mod (lSegmentWidth + lSegmentSpacing))
If TBR.Top > TR.Bottom Then TBR.Top = TR.Bottom
End If
End Sub
'==========================================================
'/---Draw Division Bars
'==========================================================
Private Sub DrawDivisions()
Dim I As Long
Dim hBR As Long
hBR = CreateSolidBrush(vbWhite)
LSet TSR = TR
If m_Orientation = 0 Then
'=======================================================================================
' Draw Horizontal ProgressBar
'---------------------------------------------------------------------------------------
For I = TBR.Left + lSegmentWidth To TBR.Right Step lSegmentWidth + lSegmentSpacing
TSR.Left = I + 1
TSR.Right = I + 1 + lSegmentSpacing
FillRect m_hDC, TSR, hBR
Next I
'---------------------------------------------------------------------------------------
Else
'=======================================================================================
' Draw Vertical ProgressBar
'---------------------------------------------------------------------------------------
For I = TBR.Bottom To TBR.Top + lSegmentWidth Step -(lSegmentWidth + lSegmentSpacing)
TSR.Top = I - 2
TSR.Bottom = I - 2 + lSegmentSpacing
FillRect m_hDC, TSR, hBR
Next I
'---------------------------------------------------------------------------------------
End If
DeleteObject hBR
End Sub
'==========================================================
'/---Draw The ProgressXP Bar Border ;)
'==========================================================
Private Sub pDrawBorder()
Dim RTemp As RECT
TR.Left = TR.Left - 3
Let RTemp = TR
DrawLine 2, 1, TR.Right - 2, 1, m_hDC, &HBEBEBE
DrawLine 2, TR.Bottom - 2, TR.Right - 2, TR.Bottom - 2, m_hDC, &HEFEFEF
DrawLine 1, 2, 1, TR.Bottom - 2, m_hDC, &HBEBEBE
DrawLine 2, 2, 2, TR.Bottom - 2, m_hDC, &HEFEFEF
DrawLine 2, 2, TR.Right - 2, 2, m_hDC, &HEFEFEF
DrawLine TR.Right - 2, 2, TR.Right - 2, TR.Bottom - 2, m_hDC, &HEFEFEF
DrawRectangle TR, GetLngColor(&H686868), m_hDC
Call SetPixelV(m_hDC, 0, 0, GetLngColor(vbWhite))
Call SetPixelV(m_hDC, 0, 1, GetLngColor(&HA6ABAC))
Call SetPixelV(m_hDC, 0, 2, GetLngColor(&H7D7E7F))
Call SetPixelV(m_hDC, 1, 0, GetLngColor(&HA7ABAC)) '//TOP RIGHT CORNER
Call SetPixelV(m_hDC, 1, 1, GetLngColor(&H777777))
Call SetPixelV(m_hDC, 2, 0, GetLngColor(&H7D7E7F))
Call SetPixelV(m_hDC, 2, 2, GetLngColor(&HBEBEBE))
Call SetPixelV(m_hDC, 0, TR.Bottom - 1, GetLngColor(vbWhite))
Call SetPixelV(m_hDC, 1, TR.Bottom - 1, GetLngColor(&HA6ABAC))
Call SetPixelV(m_hDC, 2, TR.Bottom - 1, GetLngColor(&H7D7E7F))
Call SetPixelV(m_hDC, 0, TR.Bottom - 3, GetLngColor(&H7D7E7F)) '//BOTTOM RIGHT CORNER
Call SetPixelV(m_hDC, 0, TR.Bottom - 2, GetLngColor(&HA7ABAC))
Call SetPixelV(m_hDC, 1, TR.Bottom - 2, GetLngColor(&H777777))
Call SetPixelV(m_hDC, TR.Right - 1, 0, GetLngColor(vbWhite))
Call SetPixelV(m_hDC, TR.Right - 1, 1, GetLngColor(&HBEBEBE))
Call SetPixelV(m_hDC, TR.Right - 1, 2, GetLngColor(&H7D7E7F)) '//TOP LEFT CORNER
Call SetPixelV(m_hDC, TR.Right - 2, 2, GetLngColor(&HBEBEBE))
Call SetPixelV(m_hDC, TR.Right - 2, 1, GetLngColor(&H686868))
Call SetPixelV(m_hDC, TR.Right - 1, TR.Bottom - 1, GetLngColor(vbWhite))
Call SetPixelV(m_hDC, TR.Right - 1, TR.Bottom - 2, GetLngColor(&HBEBEBE))
Call SetPixelV(m_hDC, TR.Right - 1, TR.Bottom - 3, GetLngColor(&H7D7E7F))
Call SetPixelV(m_hDC, TR.Right - 2, TR.Bottom - 2, GetLngColor(&H777777)) '//TOP RIGHT CORNER
Call SetPixelV(m_hDC, TR.Right - 2, TR.Bottom - 1, GetLngColor(&HBEBEBE))
Call SetPixelV(m_hDC, TR.Right - 3, TR.Bottom - 1, GetLngColor(&H7D7E7F))
End Sub
'==========================================================
'/---Draw The ProgressXP Bar ;)
'==========================================================
Private Sub PBarDraw()
Dim TempRect As RECT
Dim ITemp As Long
If m_Orientation = 0 Then
If TBR.Right <= 14 Then TBR.Right = 12
TempRect.Left = 4
TempRect.Right = IIf(TBR.Right + 4 > TR.Right, TBR.Right - 4, TBR.Right)
TempRect.Top = 8
TempRect.Bottom = TR.Bottom - 8
'=======================================================================================
' Draw Horizontal ProgressBar
'---------------------------------------------------------------------------------------
If m_Scrolling = ccScrollingSearch Then
GoSub HorizontalSearch
Else
DrawGradient ShiftColorXP(m_Color, 150), m_Color, 4, 3, TempRect.Right, 6, m_hDC
DrawFillRectangle TempRect, m_Color, m_hDC
DrawGradient m_Color, ShiftColorXP(m_Color, 150), 4, TempRect.Bottom - 2, TempRect.Right, 6, m_hDC
End If
Else
TempRect.Left = 9
TempRect.Right = TR.Right - 8
TempRect.Top = TBR.Top
TempRect.Bottom = TR.Bottom
'=======================================================================================
' Draw Vertical ProgressBar
'---------------------------------------------------------------------------------------
If m_Scrolling = ccScrollingSearch Then
GoSub VerticalSearch
Else
DrawGradient ShiftColorXP(m_Color, 150), m_Color, 4, TBR.Top, 4, TR.Bottom, m_hDC, True
DrawFillRectangle TempRect, m_Color, m_hDC
DrawGradient m_Color, ShiftColorXP(m_Color, 150), TR.Right - 8, TBR.Top, 4, TR.Bottom, m_hDC, True
End If
'-------------------- <-------- Gradient Color From (- to +)
'|||||||||||||||||||| <-------- Fill Color
'-------------------- <-------- Gradient Color From (+ to -)
End If
Exit Sub
HorizontalSearch:
For ITemp = 0 To 2
With TempRect
.Left = TBR.Right + ((lSegmentSpacing + 10) * (ITemp)) - (45 * ((100 - m_Value) / 100))
.Right = .Left + 10
.Top = 8
.Bottom = TR.Bottom - 8
DrawGradient ShiftColorXP(m_Color, 220 - (40 * ITemp)), ShiftColorXP(m_Color, 200 - (40 * ITemp)), .Left, 3, 9, TR.Bottom - 2, m_hDC, True
End With
Next ITemp
Return
VerticalSearch:
For ITemp = 0 To 2
With TempRect
.Left = 8
.Right = TR.Right - 8
.Top = TBR.Top + ((lSegmentSpacing + 10) * ITemp)
.Bottom = .Top + 10
DrawGradient ShiftColorXP(m_Color, 220 - (40 * ITemp)), ShiftColorXP(m_Color, 200 - (40 * ITemp)), TR.Right - 2, .Top, 2, 9, m_hDC
End With
Next ITemp
Return
End Sub
'======================================================================
'DRAWS THE PERCENT TEXT ON PROGRESS BAR
Private Function DrawTexto()
Dim ThisText As String
Dim isAlpha As Boolean
If (m_Scrolling = ccScrollingMediaPlayer Or m_Scrolling = ccScrollingMetallic) Then isAlpha = True
If m_Scrolling = ccScrollingSearch Then
ThisText = "Searching.."
Else
ThisText = Round(m_Value) & " %"
End If
If (m_ShowText) Then
Set iFnt = Font '//--New Font
hFntOld = SelectObject(m_hDC, iFnt.hFont) '//--Use the New Font
SetBkMode m_hDC, 1 '//--Transparent Text
'//--Use the Alpha Text Color Look if Progress is MediaPlayer Style, else Normal (Gray)
SetTextColor m_hDC, GetLngColor(IIf(m_Scrolling = ccScrollingMediaPlayer, &HC0C0C0, vbBlack))
CalculateAlphaTextRect ThisText '//--Calculate The Text Rectangle
'//-- If ProgressBar is already over the Text don't draw the old text, yust draw the Alpha Text
'It saves some memory
If ((TR.Right * (m_Value / 100)) <= AT.Right) Or Not isAlpha Then
DrawText m_hDC, ThisText, Len(ThisText), AT, DT_SINGLELINE
End If
SelectObject m_hDC, hFntOld 'Delete the Used Font
'//--Use the Alpha Text Look if Progress is AlPhA Style
If isAlpha Then DrawAlphaText ThisText
End If
End Function
'======================================================================
'======================================================================
'ALPHA TEXT RECT FUNCTION
Private Sub CalculateAlphaTextRect(ByVal ThisText As String)
'//--Calculates the Bounding Rects Of the Text using DT_CALCRECT
DrawText m_hDC, ThisText, Len(ThisText), AT, DT_CALCRECT
AT.Left = (TR.Right / 2) - ((AT.Right - AT.Left) / 2)
AT.Top = (TR.Bottom / 2) - ((AT.Bottom - AT.Top) / 2)
End Sub
'======================================================================
'======================================================================
'ALPHA TEXT FUNCTION
Private Sub DrawAlphaText(ByVal ThisText As String)
Set iFnt = Font '//--New Font
hFntOld = SelectObject(m_hDC, iFnt.hFont) '//--Use the New Font
SetBkMode m_hDC, 1 '//--Transparent Text
'//-- This is When the Text is Drawn
'//--Gives the Media Player Text Look (Changes Color When Progress is over the Text)
If (TR.Right * (m_Value / 100)) >= AT.Left Then
SetTextColor m_hDC, GetLngColor(IIf(m_Scrolling = ccScrollingMediaPlayer, ShiftColorXP(m_Color, 80), vbWhite))
AT.Left = (TR.Right / 2) - ((AT.Right - AT.Left) / 2)
AT.Right = (TR.Right * (m_Value / 100))
DrawText m_hDC, ThisText, Len(ThisText), AT, DT_SINGLELINE
End If
SelectObject m_hDC, hFntOld
End Sub
'======================================================================
'======================================================================
'CONVERTION FUNCTION
Private Function GetLngColor(Color As Long) As Long
If (Color And &H80000000) Then
GetLngColor = GetSysColor(Color And &H7FFFFFFF)
Else
GetLngColor = Color
End If
End Function
'======================================================================
'======================================================================
'DRAWS A BORDER RECTANGLE AREA OF AN SPECIFIED COLOR
Private Sub DrawRectangle(ByRef bRect As RECT, ByVal Color As Long, ByVal hdc As Long)
Dim hBrush As Long
hBrush = CreateSolidBrush(Color)
FrameRect hdc, bRect, hBrush
DeleteObject hBrush
End Sub
'======================================================================
'======================================================================
'DRAWS A LINE WITH A DEFINED COLOR
Public Sub DrawLine( _
ByVal X As Long, _
ByVal Y As Long, _
ByVal Width As Long, _
ByVal Height As Long, _
ByVal cHdc As Long, _
ByVal Color As Long)
Dim Pen1 As Long
Dim Pen2 As Long
Dim POS As POINTAPI
Pen1 = CreatePen(0, 1, GetLngColor(Color))
Pen2 = SelectObject(cHdc, Pen1)
MoveToEx cHdc, X, Y, POS
LineTo cHdc, Width, Height
SelectObject cHdc, Pen2
DeleteObject Pen2
DeleteObject Pen1
End Sub
'======================================================================
'======================================================================
'BLENDS A SPECIFIED COLOR TO GET XP COLOR LOOK
Private Function ShiftColorXP(ByVal MyColor As Long, ByVal Base As Long) As Long
Dim R As Long, G As Long, B As Long, Delta As Long
R = (MyColor And &HFF)
G = ((MyColor \ &H100) Mod &H100)
B = ((MyColor \ &H10000) Mod &H100)
Delta = &HFF - Base
B = Base + B * Delta \ &HFF
G = Base + G * Delta \ &HFF
R = Base + R * Delta \ &HFF
If R > 255 Then R = 255
If G > 255 Then G = 255
If B > 255 Then B = 255
ShiftColorXP = R + 256& * G + 65536 * B
End Function
'======================================================================
'======================================================================
'DRAWS A 2 COLOR GRADIENT AREA WITH A PREDEFINED DIRECTION
Public Sub DrawGradient(lEndColor As Long, lStartcolor As Long, ByVal X As Long, ByVal Y As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal hdc As Long, Optional bH As Boolean)
On Error Resume Next
''Draw a Vertical Gradient in the current HDC
Dim sR As Single, sG As Single, sB As Single
Dim eR As Single, eG As Single, eB As Single
Dim ni As Long
lEndColor = GetLngColor(lEndColor)
lStartcolor = GetLngColor(lStartcolor)
sR = (lStartcolor And &HFF)
sG = (lStartcolor \ &H100) And &HFF
sB = (lStartcolor And &HFF0000) / &H10000
eR = (lEndColor And &HFF)
eG = (lEndColor \ &H100) And &HFF
eB = (lEndColor And &HFF0000) / &H10000
sR = (sR - eR) / IIf(bH, X2, Y2)
sG = (sG - eG) / IIf(bH, X2, Y2)
sB = (sB - eB) / IIf(bH, X2, Y2)
For ni = 0 To IIf(bH, X2, Y2)
If bH Then
DrawLine X + ni, Y, X + ni, Y2, hdc, RGB(eR + (ni * sR), eG + (ni * sG), eB + (ni * sB))
Else
DrawLine X, Y + ni, X2, Y + ni, hdc, RGB(eR + (ni * sR), eG + (ni * sG), eB + (ni * sB))
End If
Next ni
End Sub
'======================================================================
'======================================================================
'BLENDS 2 COLORS WITH A PREDEFINED ALPHA VALUE
Private Function BlendColor(ByVal oColorFrom As OLE_COLOR, ByVal oColorTo As OLE_COLOR, Optional ByVal Alpha As Long = 128) As Long
Dim lCFrom As Long
Dim lCTo As Long
Dim lSrcR As Long
Dim lSrcG As Long
Dim lSrcB As Long
Dim lDstR As Long
Dim lDstG As Long
Dim lDstB As Long
lCFrom = GetLngColor(oColorFrom)
lCTo = GetLngColor(oColorTo)
lSrcR = lCFrom And &HFF
lSrcG = (lCFrom And &HFF00&) \ &H100&
lSrcB = (lCFrom And &HFF0000) \ &H10000
lDstR = lCTo And &HFF
lDstG = (lCTo And &HFF00&) \ &H100&
lDstB = (lCTo And &HFF0000) \ &H10000
BlendColor = RGB( _
((lSrcR * Alpha) / 255) + ((lDstR * (255 - Alpha)) / 255), _
((lSrcG * Alpha) / 255) + ((lDstG * (255 - Alpha)) / 255), _
((lSrcB * Alpha) / 255) + ((lDstB * (255 - Alpha)) / 255) _
)
End Function
'======================================================================
'======================================================================
'DRAWS A FILL RECTANGLE AREA OF AN SPECIFIED COLOR
Private Sub DrawFillRectangle(ByRef hRect As RECT, ByVal Color As Long, ByVal MyHdc As Long)
Dim hBrush As Long
hBrush = CreateSolidBrush(GetLngColor(Color))
FillRect MyHdc, hRect, hBrush
DeleteObject hBrush
End Sub
'======================================================================
'======================================================================
'CHECKS-CREATES CORRECT DIMENSIONS OF THE TEMP DC
Private Function ThDC(Width As Long, Height As Long) As Long
If m_ThDC = 0 Then
If (Width + Height) > 0 Then pCreate Width, Height
Else
If Width > m_lWidth Or Height > m_lHeight Then pCreate Width, Height
End If
ThDC = m_ThDC
End Function
'======================================================================
'======================================================================
'CREATES THE TEMP DC
Private Sub pCreate(ByVal Width As Long, ByVal Height As Long)
Dim lhDCC As Long
pDestroy
lhDCC = CreateDC("DISPLAY", "", "", ByVal 0&)
If lhDCC Then
m_ThDC = CreateCompatibleDC(lhDCC)
If m_ThDC Then
m_hBmp = CreateCompatibleBitmap(lhDCC, Width, Height)
If m_hBmp Then
m_hBmpOld = SelectObject(m_ThDC, m_hBmp)
If m_hBmpOld Then
m_lWidth = Width
m_lHeight = Height
DeleteDC lhDCC
Exit Sub
End If
End If
End If
DeleteDC lhDCC
pDestroy
End If
End Sub
'======================================================================
'======================================================================
'DRAWS THE TEMP DC
Public Sub pDraw( _
ByVal hdc As Long, _
Optional ByVal xSrc As Long = 0, Optional ByVal ySrc As Long = 0, _
Optional ByVal WidthSrc As Long = 0, Optional ByVal HeightSrc As Long = 0, _
Optional ByVal xDst As Long = 0, Optional ByVal yDst As Long = 0 _
)
If WidthSrc <= 0 Then WidthSrc = m_lWidth
If HeightSrc <= 0 Then HeightSrc = m_lHeight
BitBlt hdc, xDst, yDst, WidthSrc, HeightSrc, m_ThDC, xSrc, ySrc, vbSrcCopy
End Sub
'======================================================================
'======================================================================
'DESTROYS THE TEMP DC
Private Sub pDestroy()
If m_hBmpOld Then
SelectObject m_ThDC, m_hBmpOld
m_hBmpOld = 0
End If
If m_hBmp Then
DeleteObject m_hBmp
m_hBmp = 0
End If
If m_ThDC Then
DeleteDC m_ThDC
m_ThDC = 0
End If
m_lWidth = 0
m_lHeight = 0
End Sub
'======================================================================
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'===========================================================================
'USER CONTROL EVENTS
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'===========================================================================
Private Sub UserControl_Initialize()
Dim fnt As StdFont
Set fnt = New StdFont
Set Font = fnt
With UserControl
.BackColor = vbWhite
.ScaleMode = vbPixels
End With
'----------------------------------------------------------
'Default Values
hdc = UserControl.hdc
hwnd = UserControl.hwnd
m_Max = 100
m_Min = 0
m_Value = 0
m_Orientation = ccOrientationHorizontal
m_Scrolling = ccScrollingStandard
m_Color = GetLngColor(vbHighlight)
DrawProgressBar
'----------------------------------------------------------
End Sub
Private Sub UserControl_Paint()
DrawProgressBar
End Sub
Private Sub UserControl_Resize()
hdc = UserControl.hdc
End Sub
Private Sub UserControl_Terminate()
pDestroy 'Destroy Temp DC
End Sub
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'===========================================================================
'USER CONTROL PROPERTIES
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'===========================================================================
Public Property Let BrushStyle(ByVal Style As BrushStyle)
m_Brush = Style
PropertyChanged "BrushStyle"
End Property
Public Property Get Color() As OLE_COLOR
Attribute Color.VB_Description = "Returns/sets the color of the ProgressBar"
Color = m_Color
End Property
Public Property Let Color(ByVal lColor As OLE_COLOR)
m_Color = GetLngColor(lColor)
DrawProgressBar
End Property
Public Property Get Font() As IFont
Set Font = m_fnt
End Property
Public Property Set Font(ByRef fnt As IFont)
Set m_fnt = fnt 'Defined By System but can change by user choice.(ADD Property!!)
End Property
Public Property Let Font(ByRef fnt As IFont)
Set m_fnt = fnt
End Property
Public Property Get hwnd() As Long