-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathObjectColor.pbi
More file actions
1892 lines (1719 loc) · 82 KB
/
ObjectColor.pbi
File metadata and controls
1892 lines (1719 loc) · 82 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
;- Top
; -------------------------------------------------------------------------------------------------
; Name: ObjectColor.pbi
; Description: Set the Gadget Background and Text Colors automatically based on the window's color or parent container's color.
; Using #PB_Auto as a parameter for the background color, it automatically uses the parent container's color.
; Using #PB_Auto as a parameter for the text color, it uses white or black color depending on the color of the parent container, light or dark.
; The theme "Explorer" or "DarkMode_Explorer" (Windows 10 and up) is automatically applied according to the background color of each Gadget for
; ComboBox, Editor, ExplorerList, ExplorerTree, ListIcon, ListView, ScrollArea, ScrollBar, Tree
; Author: ChrisR
; Version: 1.5.2
; Date: 2024-05-02 (Creation Date: 2022-04-14)
; PB-Version: 5.73 - 6.10 x64/x86
; OS: Windows only
; Credit: PB Forum, Rashad for his help: ComboBox WM_DRAWITEM example, Colored ListIcon Header,...
; Forum: https://www.purebasic.fr/english/viewtopic.php?t=78966
; -------------------------------------------------------------------------------------------------
; Supported gadget: Canvas Container, Calendar, CheckBox, ComboBox, Container, Date, Editor, ExplorerList, ExplorerTree, Frame, HyperLink, ListIcon, ListView,
; Option, Panel, ProgressBar, ScrollArea, Spin, Splitter, String, Text, TrackBar, Tree
;
; Notes: For the ComboBoxGadget, #CBS_HASSTRINGS and #CBS_OWNERDRAWFIXED must be added at Combobox creation time, ex: ComboBoxGadget(#Combo,X,Y,W,H,#CBS_HASSTRINGS|#CBS_OWNERDRAWFIXED)
; To receive its events in the Window Callback and be drawn with the chosen colors.
; It does not work for ComboBox with #PB_ComboBox_Image constant, in this case do Not add the constants #CBS_HASSTRINGS|#CBS_OWNERDRAWFIXED
;
; For ButtonGadget, you can use JellyButtons.pbi to get nice colored buttons. It is included in IceDesign GUI Designer.
;
; -------------------------------------------------------------------------------------------------
; Add: XIncludeFile "ObjectColor.pbi"
;
;- Usages:
;
; SetObjectColor([#Window, #Gadget, BackColor, TextColor])
;
; #Window | #PB_All = All Window (Default).
; | The Window number to use.
; |
; #Gadget | #PB_All = All Supported Gadgets (Default).
; | The Gadget number to use.
; |
; BackColor | #PB_Auto = Same as parent container's color (Default).
; | The new backgound color. RGB() can be used to get a valid color value.
; | #PB_Default = to go back to the default system backgound color.
; |
; TextColor | #PB_Auto = White or Black depending on whether the background color is dark or light (Default).
; | The new text color. RGB() can be used to get a valid color value.
; | #PB_Default: to go back to the default system text color.
;
; For all gadgets with automatic background color and text color use: SetObjectColor()
;
; ---------------------------------------------
;
; SetObjectColorType([Type.s]) Optional
; |
; Type.s: | Without Type for all supported Gadget. It is done automatically if SetObjectColorType() is not used.
; | "NoEdit" for all supported Gadget except String and Editor.
; | "ColorStatic" for CheckBox, Frame, Option and TrackBar only (WM_CTLCOLORSTATIC).
; | 1 or multiple #PB_GadgetType_xxxxx separated by comma. The parameter is a String, so between quotes. Ex: SetObjectColorType("#PB_GadgetType_CheckBox, #PB_GadgetType_Option").
;
;
; ---------------------------------------------
;
; The theme "Explorer" or "DarkMode_Explorer" (Windows 10 and up) is automatically applied according to the Background Color of each Gadget.
; Gadget supported: ComboBox, Editor, ExplorerList, ExplorerTree, ListIcon, ListView, ScrollArea, ScrollBar, Tree
; However, after calling SetObjectColor(), you can change the applied theme by using one of the 2 macros below:
; For example, if you have a window With a Dark Background Color And a ScrollArea With a Light Color,
; By default, the Light Theme will be applied for the ScollArea and its ScrollBars related to the ScrollArea Color.
; But you may want to change it to a Dark Theme to match the Window which is in Dark Color. It would be like this
; SetObjectColor(#PB_All, #PB_All, #Black)
; SetObjectColor(#Windows, #ScrollArea, #Gray)
; SetDarkTheme(#ScrollArea)
;
; SetDarkTheme(Gadget) Optional
; Apply the "DarkMode_Explorer" Theme if OSVersion >= Windows_10, otherwise the "Explorer" theme is applied
;
; SetExplorerTheme(Gadget) Optional
; Apply the "Explorer" Theme if OSVersion >= Vista
;
; ---------------------------------------------
;
; To Debug with the hierarchical list of gadgets with their colors, change the constant #DebugON = #True
;
; -------------------------------------------------------------------------------------------------
EnableExplicit
#DebugON = #False ; #True
#EditAccentColor = #True ; #False
#UseUxGripper = #False ; #False = Custom, #True = Uxtheme. For Splitter
#LargeGripper = #True ; #False
#SplitterBorder = #True ; #False
#PB_Auto = -2
#PB_None = -3
; Add: XIncludeFile "JellyButtons.pbi" in your main code to add nice buttons
Structure SObjectC
Level.i ; If Level = 1, Parent is a Window else a Gadget
ObjectID.i
Type.i
IsContainer.b
ParentObject.i
ParentObjectID.i
GParentObjectID.i ; Temporary Loaded for ScrollArea and Panel, it is then reset to 0 or used to store the Splitter gripper image
BackMode.i
BackColor.i
TextMode.i
TextColor.i
OldProc.i
EndStructure
Global NewMap ObjectC.SObjectC()
Global NewMap ObjectCType()
Global NewMap ObjectCBrush()
Global Dim WinObjectC(1, 0)
CompilerIf Not (Defined(PB_Globals, #PB_Structure))
Structure PB_Globals
CurrentWindow.i
FirstOptionGadget.i
DefaultFont.i
*PanelStack
PanelStackIndex.l
PanelStackSize.l
ToolTipWindow.i
EndStructure
CompilerEndIf
Import ""
CompilerIf Not(Defined(PB_Object_Count, #PB_Procedure)) : PB_Object_Count(PB_Gadget_Objects) : CompilerEndIf
CompilerIf Not(Defined(PB_Object_EnumerateAll, #PB_Procedure)) : PB_Object_EnumerateAll(Object, *Object, ObjectData) : CompilerEndIf
CompilerIf Not(Defined(PB_Object_EnumerateStart, #PB_Procedure)) : PB_Object_EnumerateStart(PB_Gadget_Objects) : CompilerEndIf
CompilerIf Not(Defined(PB_Object_EnumerateNext, #PB_Procedure)) : PB_Object_EnumerateNext(PB_Gadget_Objects, *Object.Integer) : CompilerEndIf
CompilerIf Not(Defined(PB_Object_EnumerateAbort, #PB_Procedure)) : PB_Object_EnumerateAbort(PB_Gadget_Objects) : CompilerEndIf
CompilerIf Not (Defined(PB_Object_GetThreadMemory, #PB_Procedure)) : PB_Object_GetThreadMemory(*Mem) : CompilerEndIf
CompilerIf Not(Defined(PB_Gadget_Objects, #PB_Variable)) : PB_Gadget_Objects.i : CompilerEndIf
CompilerIf Not(Defined(PB_Window_Objects, #PB_Variable)) : PB_Window_Objects.i : CompilerEndIf
CompilerIf Not (Defined(PB_Gadget_Globals, #PB_Variable)) : PB_Gadget_Globals.i : CompilerEndIf
EndImport
; GetParent
Declare IsContainerOC(Gadget)
Declare CountWinObjectC()
Declare ObjectCB(Object, *Object, ObjectData)
Declare WinHierarchy(ParentObjectID, ParentObject, FirstPassDone = #False)
Declare CleanUpCanvas()
Declare LoadObjectC()
Declare GetParent(Gadget)
Declare GetParentBackColor(Gadget)
Declare GetWindowRoot(Gadget)
Declare GetParentID(Gadget)
Declare ParentIsWindow(Gadget)
Declare ParentIsGadget(Gadget)
Declare CountChildGadgets(ParentObject, GrandChildren = #False, FirstPassDone = #False)
Declare EnumWinChildColor(ParentObject, FirstPassDone = #False)
Declare EnumChildColor(Window = #PB_All)
; ObjectColor
Declare IsDarkColorOC(Color)
Declare AccentColorOC(Color, AddColorValue)
Declare FadeColorOC(Color, Percent, FadeColor = $808080)
Declare ReverseColorOC(Color)
Declare BackDefaultColor()
Declare TextDefaultColor()
Declare SplitterCalc(hWnd, *rc.RECT)
Declare SplitterPaint(hWnd, hdc, *rc.RECT, BackColor, Gripper)
Declare SplitterProc(hWnd, uMsg, wParam, lParam)
Declare ListIconProc(hWnd, uMsg, wParam, lParam)
Declare PanelProc(hWnd, uMsg, wParam, lParam)
Declare CalendarProc(hWnd, uMsg, wParam, lParam)
Declare EditorProc(hWnd, uMsg, wParam, lParam)
Declare WinCallback(hWnd, uMsg, wParam, lParam)
Declare SetObjectTheme(Gadget, Theme.s)
Declare ToolTipHandleOC()
Declare.s GadgetTypeToString(Gadget)
Declare TypetoValue(Type.s)
Declare SetObjectColorType(Type.s = "", Value = 1)
Declare ObjectColor(Gadget, BackGroundColor, ParentBackColor, FrontColor)
Declare LoopObjectColor(Window, ParentObject, BackGroundColor, FrontColor, FirstPassDone = #False)
Declare SetObjectColor(Window = #PB_All, Gadget = #PB_All, BackGroundColor = #PB_Auto, FrontColor = #PB_Auto)
Macro SetDarkTheme(_Gadget_)
If OSVersion() >= #PB_OS_Windows_10
SetObjectTheme(_Gadget_, "DarkMode_Explorer")
ElseIf OSVersion() >= #PB_OS_Windows_Vista
SetObjectTheme(_Gadget_, "Explorer")
EndIf
EndMacro
Macro SetExplorerTheme(_Gadget_)
If OSVersion() >= #PB_OS_Windows_Vista
SetObjectTheme(_Gadget_, "Explorer")
EndIf
EndMacro
Macro ProcedureReturnIf(Cond, ReturnVal = 0)
If Cond
ProcedureReturn ReturnVal
EndIf
EndMacro
;-
;- ----- Private GetParent -----
Procedure IsContainerOC(Gadget)
; Procedure IsContainer based on procedure IsCanvasContainer by mk-soft: https://www.purebasic.fr/english/viewtopic.php?t=79002
Select GadgetType(Gadget)
Case #PB_GadgetType_Container, #PB_GadgetType_Panel, #PB_GadgetType_ScrollArea, #PB_GadgetType_Splitter
ProcedureReturn #True
Case #PB_GadgetType_Canvas
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
If GetWindowLongPtr_(GadgetID(Gadget), #GWL_STYLE) & #WS_CLIPCHILDREN
ProcedureReturn #True
EndIf
CompilerCase #PB_OS_MacOS
Protected sv, count
sv = CocoaMessage(0, GadgetID(Gadget), "subviews")
count = CocoaMessage(0, sv, "count")
ProcedureReturn count
CompilerCase #PB_OS_Linux
Protected GList, count
GList = gtk_container_get_children_(GadgetID(Gadget))
If GList
count = g_list_length_(GList)
g_list_free_(GList)
ProcedureReturn count
EndIf
CompilerEndSelect
EndSelect
ProcedureReturn #False
EndProcedure
Procedure CountWinObjectC()
Protected CountWinObjectC, I
For I = 0 To ArraySize(WinObjectC(), 2)
If WinObjectC(1, I)
CountWinObjectC + 1
EndIf
Next
ProcedureReturn CountWinObjectC
EndProcedure
Procedure ObjectCB(Object, *Object, ObjectData)
If FindMapElement(ObjectC(), Str(Object)) = 0
With ObjectC(Str(Object))
\ObjectID = GadgetID(Object)
\Type = GadgetType(Object)
\IsContainer = IsContainerOC(Object)
\ParentObjectID = GetParent_(\ObjectID)
\GParentObjectID = GetParent_(\ParentObjectID)
\BackMode = #PB_None
\TextMode = #PB_None
\BackColor = #PB_None
\TextColor = #PB_None
EndWith
EndIf
ProcedureReturn #True
EndProcedure
Procedure WinHierarchy(ParentObjectID, ParentObject, FirstPassDone = #False)
Static Level
Protected ObjectType
If FirstPassDone = #False
Level = 0
FirstPassDone = #True
EndIf
Level + 1
PushMapPosition(ObjectC())
ResetMap(ObjectC())
With ObjectC()
While NextMapElement(ObjectC())
If Level > 1 And IsGadget(ParentObject) : ObjectType = GadgetType(ParentObject) : Else : ObjectType = 0 : EndIf
If \ParentObjectID = ParentObjectID Or (\GParentObjectID = ParentObjectID And (ObjectType = #PB_GadgetType_Panel Or ObjectType = #PB_GadgetType_ScrollArea))
\Level = Level
\ParentObject = ParentObject
If Not(\ParentObjectID = ParentObjectID)
\ParentObjectID = \GParentObjectID
EndIf
If \OldProc = 0 ; To keep the gripper for Splitter saved in GParentObjectID in case of a new enumeration
\GParentObjectID = 0
EndIf
If \IsContainer
WinHierarchy(\ObjectID, Val(MapKey(ObjectC())), FirstPassDone)
Level - 1
EndIf
EndIf
Wend
EndWith
PopMapPosition(ObjectC())
EndProcedure
Procedure CleanUpCanvas()
PushMapPosition(ObjectC())
ResetMap(ObjectC())
With ObjectC()
While NextMapElement(ObjectC())
If \Type = #PB_GadgetType_Canvas And \IsContainer = #False
DeleteMapElement(ObjectC())
EndIf
Wend
EndWith
PopMapPosition(ObjectC())
EndProcedure
Procedure LoadObjectC()
Protected window, CountWinObjectC, I
CountWinObjectC = PB_Object_Count(PB_Window_Objects)
ProcedureReturnIf(CountWinObjectC = 0)
ReDim WinObjectC(1, CountWinObjectC - 1)
CountWinObjectC = 0
PB_Object_EnumerateStart(PB_Window_Objects)
While PB_Object_EnumerateNext(PB_Window_Objects, @window)
WinObjectC(0, CountWinObjectC) = Window
WinObjectC(1, CountWinObjectC) = WindowID(Window)
CountWinObjectC + 1
Wend
PB_Object_EnumerateAbort(PB_Window_Objects)
PB_Object_EnumerateAll(PB_Gadget_Objects, @ObjectCB(), 0)
CleanUpCanvas()
If MapSize(ObjectC()) > 0
; Pass through the hierarchy for each window
CountWinObjectC = CountWinObjectC() - 1
For I = 0 To CountWinObjectC
WinHierarchy(WinObjectC(1, I), WinObjectC(0, I))
Next
Else
ProcedureReturn #False
EndIf
ProcedureReturn #True
EndProcedure
;- ----- Private GetParent -----
;-
;- ----- Public GetParent -----
Procedure GetParent(Gadget)
Protected ParentObject = #PB_Default
If MapSize(ObjectC()) = 0 : LoadObjectC() : ProcedureReturnIf(CountWinObjectC() = 0) : EndIf
With ObjectC()
PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
ParentObject = \ParentObject
EndIf
PopMapPosition(ObjectC())
EndWith
ProcedureReturn ParentObject
EndProcedure
Procedure GetParentBackColor(Gadget)
Protected ParentObject, ParentIsWindow, BackColor = #PB_Default
With ObjectC()
PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If \Level = 1 : ParentIsWindow = #True : EndIf
ParentObject = \ParentObject
EndIf
If ParentIsWindow
BackColor = GetWindowColor(ParentObject)
ElseIf FindMapElement(ObjectC(), Str(ParentObject))
BackColor = \BackColor
EndIf
PopMapPosition(ObjectC())
If BackColor = #PB_Default : BackColor = BackDefaultColor() : EndIf
EndWith
ProcedureReturn BackColor
EndProcedure
Procedure GetWindowRoot(Gadget)
Protected ParentObject = Gadget
If MapSize(ObjectC()) = 0 : LoadObjectC() : ProcedureReturnIf(CountWinObjectC() = 0) : EndIf
With ObjectC()
PushMapPosition(ObjectC())
Repeat
If FindMapElement(ObjectC(), Str(ParentObject))
ParentObject = \ParentObject
Else
ParentObject = #PB_Default
Break ; It should not happen
EndIf
Until \Level = 1
PopMapPosition(ObjectC())
EndWith
ProcedureReturn ParentObject
EndProcedure
Procedure GetParentID(Gadget)
Protected ParentObjectID = #PB_Default
If MapSize(ObjectC()) = 0 : LoadObjectC() : ProcedureReturnIf(CountWinObjectC() = 0) : EndIf
With ObjectC()
PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If \Level = 1
ParentObjectID = WindowID(\ParentObject)
Else
ParentObjectID = GadgetID(\ParentObject)
EndIf
EndIf
PopMapPosition(ObjectC())
EndWith
ProcedureReturn ParentObjectID
EndProcedure
Procedure ParentIsWindow(Gadget)
Protected Result = #PB_Default
If MapSize(ObjectC()) = 0 : LoadObjectC() : ProcedureReturnIf(CountWinObjectC() = 0) : EndIf
With ObjectC()
PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If \Level = 1
Result = #True
Else
Result = #False
EndIf
EndIf
PopMapPosition(ObjectC())
EndWith
ProcedureReturn Result
EndProcedure
Procedure ParentIsGadget(Gadget)
Protected Result = #PB_Default
If MapSize(ObjectC()) = 0 : LoadObjectC() : ProcedureReturnIf(CountWinObjectC() = 0) : EndIf
With ObjectC()
PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If \Level > 1
Result = #True
Else
Result = #False
EndIf
EndIf
PopMapPosition(ObjectC())
EndWith
ProcedureReturn Result
EndProcedure
Procedure CountChildGadgets(ParentObject, GrandChildren = #False, FirstPassDone = #False)
Static Level, Count
Protected ReturnVal
With ObjectC()
If FirstPassDone = 0
If MapSize(ObjectC()) = 0 : LoadObjectC() : ProcedureReturnIf(CountWinObjectC() = 0) : EndIf
If IsWindow(ParentObject)
Level = 0
ElseIf IsGadget(ParentObject)
PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(ParentObject))
If Not(\IsContainer)
ReturnVal = #True
EndIf
Level = \Level
EndIf
PopMapPosition(ObjectC())
EndIf
Count = 0
FirstPassDone = #True
EndIf
If ReturnVal
ProcedureReturn #PB_Default
EndIf
Level + 1
PushMapPosition(ObjectC())
ResetMap(ObjectC())
While NextMapElement(ObjectC())
If \Level = Level And \ParentObject = ParentObject
Count + 1
If GrandChildren And \IsContainer
CountChildGadgets(Val(MapKey(ObjectC())), GrandChildren, FirstPassDone)
Level - 1
EndIf
EndIf
Wend
PopMapPosition(ObjectC())
EndWith
ProcedureReturn Count
EndProcedure
Procedure EnumWinChildColor(ParentObject, FirstPassDone = #False)
Static Level
Protected BackColor, ReturnVal
If FirstPassDone = 0
If MapSize(ObjectC()) = 0 : LoadObjectC() : ProcedureReturnIf(CountWinObjectC() = 0) : EndIf
If IsWindow(ParentObject)
Level = 0
BackColor = GetWindowColor(ParentObject)
Debug "Enum Child Gadget of Window " + LSet(Str(ParentObject), 10) + "| WindowID " + LSet(Str(WindowID(ParentObject)), 10) + "(Level = 0)" +
" - BackColor RGB(" + Red(BackColor) + "," + Green(BackColor) + "," + Blue(BackColor) + ")"
Else
ProcedureReturn #PB_Default
EndIf
FirstPassDone = #True
EndIf
Level + 1
PushMapPosition(ObjectC())
ResetMap(ObjectC())
With ObjectC()
While NextMapElement(ObjectC())
If \Level = Level And \ParentObject = ParentObject
Debug LSet("", \Level * 4 , " ") + LSet(GadgetTypeToString(Val(MapKey(ObjectC()))), 14) + LSet(MapKey(ObjectC()), 10) + "ParentGadget " + LSet(Str(\ParentObject), 10) + "| GadgetID " + LSet(Str(\ObjectID), 10) + "ParentGadgetID " + LSet(Str(\ParentObjectID), 10) + "(Level = " + Str(\Level) + ")" +
" - BackMode: " +Str(\BackMode) + " RGB(" + Red(\BackColor) + "," + Green(\BackColor) + "," + Blue(\BackColor) + ")" +
" - TextMode: " +Str(\TextMode) + " RGB(" + Red(\TextColor) + "," + Green(\TextColor) + "," + Blue(\TextColor) + ")"
If \IsContainer
EnumWinChildColor(Val(MapKey(ObjectC())), FirstPassDone)
Level - 1
EndIf
EndIf
Wend
EndWith
PopMapPosition(ObjectC())
EndProcedure
Procedure EnumChildColor(Window = #PB_All)
ProcedureReturnIf(MapSize(ObjectC()) = 0)
Protected I
If Window = #PB_All
Protected CountWinObjectC = CountWinObjectC() - 1
For I = 0 To CountWinObjectC
EnumWinChildColor(WinObjectC(0, I))
Debug ""
Next
Else
If IsWindow(Window)
EnumWinChildColor(Window)
EndIf
EndIf
EndProcedure
;- ----- Public GetParent -----
;-
;- ----- Play with Colors -----
Procedure IsDarkColorOC(Color)
If Red(Color)*0.299 + Green(Color)*0.587 +Blue(Color)*0.114 < 128 ; Based on Human perception of color, following the RGB values (0.299, 0.587, 0.114)
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
Procedure AccentColorOC(Color, AddColorValue)
Protected R, G, B
R = Red(Color) + AddColorValue : If R > 255 : R = 255 : EndIf : If R < 0 : R = 0 : EndIf
G = Green(Color) + AddColorValue : If G > 255 : G = 255 : EndIf : If G < 0 : G = 0 : EndIf
B = Blue(Color) + AddColorValue : If B > 255 : B = 255 : EndIf : If B < 0 : B = 0 : EndIf
ProcedureReturn RGB(R, G, B)
EndProcedure
Procedure FadeColorOC(Color, Percent, FadeColor = $808080)
Protected R, G, B
R = Red(FadeColor) * Percent / 100 + Red(Color) * (100 - Percent) / 100 : If R > 255 : R = 255 : EndIf
G = Green(FadeColor) * Percent / 100 + Green(Color) * (100 - Percent) / 100 : If G > 255 : G = 255 : EndIf
B = Blue(FadeColor) * Percent / 100 + Blue(Color) * (100 - Percent) / 100 : If B > 255 : B = 255 : EndIf
ProcedureReturn RGB(R, G, B)
EndProcedure
Procedure ReverseColorOC(Color)
ProcedureReturn RGB(255 - Red(Color), 255 - Green(Color), 255 - Blue(Color))
EndProcedure
Procedure BackDefaultColor()
If OSVersion() < #PB_OS_Windows_10
ProcedureReturn GetSysColor_(#COLOR_BTNFACE)
Else
ProcedureReturn GetSysColor_(#COLOR_3DFACE)
EndIf
EndProcedure
Procedure TextDefaultColor()
ProcedureReturn GetSysColor_(#COLOR_BTNTEXT)
EndProcedure
;- ----- End Colors -----
;-
;- ----- CallBack -----
Procedure SplitterCalc(hWnd, *rc.RECT)
Protected hWnd1, hWnd2, r1.RECT, r2.RECT
hWnd1 = GadgetID(GetGadgetAttribute(GetDlgCtrlID_(hWnd), #PB_Splitter_FirstGadget))
hWnd2 = GadgetID(GetGadgetAttribute(GetDlgCtrlID_(hWnd), #PB_Splitter_SecondGadget))
GetWindowRect_(hWnd1, r1)
OffsetRect_(r1, -r1\left, -r1\top)
If IsRectEmpty_(r1) = 0
MapWindowPoints_(hWnd1, hWnd, r1, 2)
SubtractRect_(*rc, *rc, r1)
EndIf
GetWindowRect_(hWnd2, r2)
OffsetRect_(r2, -r2\left, -r2\top)
If IsRectEmpty_(r2) = 0
MapWindowPoints_(hWnd2, hWnd, r2, 2)
SubtractRect_(*rc, *rc, r2)
EndIf
EndProcedure
Procedure SplitterPaint(hWnd, hdc, *rc.RECT, BackColor, Gripper)
CompilerIf #SplitterBorder
If IsDarkColorOC(BackColor) : SetDCBrushColor_(hdc, AccentColorOC(BackColor, 60)) : Else : SetDCBrushColor_(hdc, AccentColorOC(BackColor, -60)) : EndIf
CompilerElse
If IsDarkColorOC(BackColor) : BackColor = AccentColorOC(BackColor, 60) : Else : BackColor = AccentColorOC(BackColor, -60) : EndIf
SetDCBrushColor_(hdc, BackColor)
CompilerEndIf
FrameRect_(hdc, *rc, GetStockObject_(#DC_BRUSH))
InflateRect_(*rc, -1, -1)
SetDCBrushColor_(hdc, BackColor)
FillRect_(hdc, *rc, GetStockObject_(#DC_BRUSH))
CompilerIf #UseUxGripper
Protected htheme = OpenThemeData_(hWnd, "Rebar")
If htheme
If *rc\right-*rc\left < *rc\bottom-*rc\top
CompilerIf #LargeGripper
InflateRect_(*rc, (*rc\bottom-*rc\top-5)/2, -(*rc\bottom-*rc\top-1)/2+14)
CompilerElse
InflateRect_(*rc, (*rc\bottom-*rc\top-5)/2, -(*rc\bottom-*rc\top-1)/2+9)
CompilerEndIf
DrawThemeBackground_(htheme, hdc, 1, 0, *rc, 0)
Else
CompilerIf #LargeGripper
InflateRect_(*rc, -(*rc\right-*rc\left-1)/2+14, (*rc\bottom-*rc\top-5)/2)
CompilerElse
InflateRect_(*rc, -(*rc\right-*rc\left-1)/2+9, (*rc\bottom-*rc\top-5)/2)
CompilerEndIf
DrawThemeBackground_(htheme, hdc, 2, 0, *rc, 0)
EndIf
CloseThemeData_(htheme)
EndIf
CompilerElse
If *rc\right-*rc\left < *rc\bottom-*rc\top
CompilerIf #LargeGripper
InflateRect_(*rc, (*rc\right-*rc\left-5)/2, -(*rc\bottom-*rc\top-1)/2+14)
CompilerElse
InflateRect_(*rc, (*rc\right-*rc\left-5)/2, -(*rc\bottom-*rc\top-1)/2+9)
CompilerEndIf
Else
CompilerIf #LargeGripper
InflateRect_(*rc, -(*rc\right-*rc\left-1)/2+14, (*rc\bottom-*rc\top-5)/2)
CompilerElse
InflateRect_(*rc, -(*rc\right-*rc\left-1)/2+9, (*rc\bottom-*rc\top-5)/2)
CompilerEndIf
EndIf
SetBrushOrgEx_(hdc, *rc\left, *rc\top, 0)
FillRect_(hdc, *rc, Gripper)
SetBrushOrgEx_(hdc, 0, 0, 0)
CompilerEndIf
EndProcedure
Procedure SplitterProc(hWnd, uMsg, wParam, lParam)
Protected Gadget = GetDlgCtrlID_(hWnd), BackColor, Gripper, Found, ps.PAINTSTRUCT
Protected OldSplitterProc = ObjectC(Str(Gadget))\OldProc
With ObjectC()
Select uMsg
Case #WM_NCDESTROY
If FindMapElement(ObjectC(), Str(Gadget))
If \GParentObjectID : DeleteObject_(\GParentObjectID) : EndIf ; Delete the Pattern Brush stored in GParentObjectID field
If \OldProc
SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, \OldProc)
EndIf
DeleteMapElement(ObjectC())
EndIf
; Delete map element for all children's gadgets that no longer exist
If MapSize(ObjectC()) > 0
ResetMap(ObjectC())
While NextMapElement(ObjectC())
If Not(IsGadget(Val(MapKey(ObjectC()))))
If \OldProc
SetWindowLongPtr_(\ObjectID, #GWLP_WNDPROC, \OldProc)
EndIf
DeleteMapElement(ObjectC())
EndIf
Wend
EndIf
;ProcedureReturn #False
Case #WM_PAINT
;PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If Not(\BackMode = #PB_Default And \TextMode = #PB_Default)
BackColor = \BackColor
Gripper = \GParentObjectID
Found = #True
EndIf
EndIf
;PopMapPosition(ObjectC())
If Found = #False Or BackColor = #PB_None : ProcedureReturn CallWindowProc_(OldSplitterProc, hWnd, uMsg, wParam, lParam) : EndIf
If #DebugON : Debug LSet(GadgetTypeToString(Gadget) + ": ", 22) + LSet(Str(Gadget), 10) + " - Back RGB(" + Str(Red(BackColor)) + ", " + Str(Green(BackColor)) + ", " + Str(Blue(BackColor)) + ")" : EndIf
BeginPaint_(hWnd, ps)
SplitterCalc(hWnd, ps\rcPaint)
SplitterPaint(hWnd, ps\hdc, ps\rcPaint, BackColor, Gripper)
EndPaint_(hWnd, ps)
ProcedureReturn #False
Case #WM_ERASEBKGND
ProcedureReturn #True
Case #WM_LBUTTONDBLCLK
PostEvent(#PB_Event_Gadget, EventWindow(), Gadget, #PB_EventType_LeftDoubleClick)
EndSelect
EndWith
ProcedureReturn CallWindowProc_(OldSplitterProc, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure ListIconProc(hWnd, uMsg, wParam, lParam)
Protected BackColor, TextColor, Text.s, Found
Protected Gadget = GetDlgCtrlID_(hWnd), *pnmHDR.NMHDR, *pnmCDraw.NMCUSTOMDRAW
Protected Result = CallWindowProc_(ObjectC(Str(Gadget))\OldProc, hWnd, uMsg, wParam, lParam)
With ObjectC()
Select uMsg
Case #WM_NCDESTROY
If FindMapElement(ObjectC(), Str(Gadget))
If \OldProc
SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, \OldProc)
EndIf
DeleteMapElement(ObjectC())
EndIf
;ProcedureReturn #False
Case #WM_NOTIFY
*pnmHDR = lparam
If *pnmHDR\code = #NM_CUSTOMDRAW ; Get handle to ListIcon and ExplorerList Header Control
;PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If Not(\BackMode = #PB_Default And \TextMode = #PB_Default)
BackColor = \BackColor
TextColor = \TextColor
Found = #True
EndIf
EndIf
;PopMapPosition(ObjectC())
If Found = #False Or BackColor = #PB_None : ProcedureReturn Result : EndIf
*pnmCDraw = lparam
Select *pnmCDraw\dwDrawStage ; Determine drawing stage
Case #CDDS_PREPAINT
Result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
If #DebugON : Debug LSet(GadgetTypeToString(Gadget) + " Header: ", 22) + LSet(Str(Gadget), 10) + " - Back RGB(" + Str(Red(BackColor)) + ", " + Str(Green(BackColor)) + ", " + Str(Blue(BackColor)) + ")" +
" - Text RGB(" + Str(Red(TextColor)) + ", " + Str(Green(TextColor)) + ", " + Str(Blue(TextColor)) + ")" : EndIf
Text = GetGadgetItemText(Gadget, -1, *pnmCDraw\dwItemSpec)
If *pnmCDraw\uItemState & #CDIS_SELECTED
DrawFrameControl_(*pnmCDraw\hdc, *pnmCDraw\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH | #DFCS_PUSHED)
*pnmCDraw\rc\left + 1 : *pnmCDraw\rc\top + 1
Else
DrawFrameControl_(*pnmCDraw\hdc, *pnmCDraw\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH)
EndIf
*pnmCDraw\rc\bottom - 1 : *pnmCDraw\rc\right - 1
SetBkMode_(*pnmCDraw\hdc, #TRANSPARENT)
If IsDarkColorOC(BackColor) : BackColor = AccentColorOC(BackColor, 40) : Else : BackColor = AccentColorOC(BackColor, -40) : EndIf
If Not(FindMapElement(ObjectCBrush(), Str(BackColor)))
ObjectCBrush(Str(BackColor)) = CreateSolidBrush_(BackColor)
EndIf
;Debug Str(Gadget) + ": " + Str(DesktopScaledX(GadgetWidth(Gadget))) + " - (" + Str(*pnmCDraw\rc\left) + ", " + Str(*pnmCDraw\rc\top) + ", " + Str(*pnmCDraw\rc\right) + ", " + Str(*pnmCDraw\rc\bottom) + ")"
;If *pnmCDraw\rc\right < DesktopScaledX(GadgetWidth(Gadget))
; *pnmCDraw\rc\right = DesktopScaledX(GadgetWidth(Gadget))
;EndIf
FillRect_(*pnmCDraw\hdc, *pnmCDraw\rc, ObjectCBrush(Str(BackColor)))
If IsWindowEnabled_(GadgetID(Gadget)) = #False
If IsDarkColorOC(TextColor) : TextColor = $909090 : Else : TextColor = $707070 : EndIf
EndIf
SetTextColor_(*pnmCDraw\hdc, TextColor)
If *pnmCDraw\rc\right > *pnmCDraw\rc\left
DrawText_(*pnmCDraw\hdc, @Text, Len(Text), *pnmCDraw\rc, #DT_CENTER | #DT_VCENTER | #DT_SINGLELINE | #DT_END_ELLIPSIS)
EndIf
Result = #CDRF_SKIPDEFAULT
EndSelect
EndIf
EndSelect
EndWith
ProcedureReturn Result
EndProcedure
Procedure PanelProc(hWnd, uMsg, wParam, lParam)
Protected BackColor, ParentBackColor, Found
Protected Gadget = GetDlgCtrlID_(hWnd), *DrawItem.DRAWITEMSTRUCT, Rect.Rect
Protected OldPanelProc = ObjectC(Str(Gadget))\OldProc
With ObjectC()
Select uMsg
Case #WM_NCDESTROY
If FindMapElement(ObjectC(), Str(Gadget))
If \OldProc
SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, \OldProc)
EndIf
DeleteMapElement(ObjectC())
EndIf
; Delete map element for all children's gadgets that no longer exist
If MapSize(ObjectC()) > 0
ResetMap(ObjectC())
While NextMapElement(ObjectC())
If Not(IsGadget(Val(MapKey(ObjectC()))))
If \OldProc
SetWindowLongPtr_(\ObjectID, #GWLP_WNDPROC, \OldProc)
EndIf
DeleteMapElement(ObjectC())
EndIf
Wend
EndIf
;ProcedureReturn #False
Case #WM_ENABLE
InvalidateRect_(hWnd, #Null, #True)
ProcedureReturn #True
Case #WM_ERASEBKGND
;PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If Not(\BackMode = #PB_Default And \TextMode = #PB_Default)
BackColor = \BackColor
Found = #True
EndIf
EndIf
;PopMapPosition(ObjectC())
If Found = #False Or BackColor = #PB_None : ProcedureReturn CallWindowProc_(OldPanelProc, hWnd, uMsg, wParam, lParam) : EndIf
;If #DebugON : Debug "WM_ERASEBKGND " + LSet(GadgetTypeToString(Gadget) + ": ", 22) + LSet(Str(Gadget), 10) + " - Back RGB(" + Str(Red(BackColor)) + ", " + Str(Green(BackColor)) + ", " + Str(Blue(BackColor)) + ")" : EndIf
*DrawItem.DRAWITEMSTRUCT = wParam
; Protected PanelImgList = SendMessage_(hWnd, #TCM_GETIMAGELIST, 0, 0)
GetClientRect_(hWnd, Rect)
If Not(FindMapElement(ObjectCBrush(), Str(BackColor)))
ObjectCBrush(Str(BackColor)) = CreateSolidBrush_(BackColor)
EndIf
FillRect_(wParam, @Rect, ObjectCBrush(Str(BackColor)))
ParentBackColor = GetParentBackColor(Gadget)
If Not(FindMapElement(ObjectCBrush(), Str(ParentBackColor)))
ObjectCBrush(Str(ParentBackColor)) = CreateSolidBrush_(ParentBackColor)
EndIf
Rect\top = 0 : Rect\bottom = GetGadgetAttribute(Gadget, #PB_Panel_TabHeight)
FillRect_(wParam, @Rect, ObjectCBrush(Str(ParentBackColor)))
ProcedureReturn #True
EndSelect
EndWith
ProcedureReturn CallWindowProc_(OldPanelProc, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure CalendarProc(hWnd, uMsg, wParam, lParam)
Protected Gadget = GetDlgCtrlID_(hWnd), TextColor, Found
Protected Result = CallWindowProc_(ObjectC(Str(Gadget))\OldProc, hWnd, uMsg, wParam, lParam)
With ObjectC()
Select uMsg
Case #WM_NCDESTROY
If FindMapElement(ObjectC(), Str(Gadget))
If \OldProc
SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, \OldProc)
EndIf
DeleteMapElement(ObjectC())
EndIf
;ProcedureReturn #False
Case #WM_ENABLE
;PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If Not(\BackMode = #PB_Default And \TextMode = #PB_Default)
TextColor = \TextColor
Found = #True
EndIf
EndIf
;PopMapPosition(ObjectC())
If Found = #False Or TextColor = #PB_None : ProcedureReturn Result : EndIf
If wParam = #False
If IsDarkColorOC(TextColor) : TextColor = $909090 : Else : TextColor = $707070 : EndIf
EndIf
SendMessage_(hWnd, #MCM_SETCOLOR, #MCSC_TEXT, TextColor)
SendMessage_(hWnd, #MCM_SETCOLOR, #MCSC_TITLETEXT, TextColor)
SendMessage_(hWnd, #MCM_SETCOLOR, #MCSC_TRAILINGTEXT, TextColor)
ProcedureReturn #False
EndSelect
EndWith
ProcedureReturn Result
EndProcedure
Procedure EditorProc(hWnd, uMsg, wParam, lParam)
Protected Gadget = GetDlgCtrlID_(hWnd), BackColor, TextColor, Found, Rect.RECT
Protected Result = CallWindowProc_(ObjectC(Str(Gadget))\OldProc, hWnd, uMsg, wParam, lParam)
With ObjectC()
Select uMsg
Case #WM_NCDESTROY
If FindMapElement(ObjectC(), Str(Gadget))
If \OldProc
SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, \OldProc)
EndIf
DeleteMapElement(ObjectC())
EndIf
;ProcedureReturn #False
Case #WM_ENABLE
;PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If Not(\BackMode = #PB_Default And \TextMode = #PB_Default)
TextColor = \TextColor
Found = #True
EndIf
EndIf
;PopMapPosition(ObjectC())
If Found = #False Or TextColor = #PB_None : ProcedureReturn Result : EndIf
If wParam
SetWindowLongPtr_(GadgetID(Gadget), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(Gadget), #GWL_EXSTYLE) &~ #WS_EX_TRANSPARENT)
SetGadgetColor(Gadget, #PB_Gadget_FrontColor, TextColor)
Else
SetWindowLongPtr_(GadgetID(Gadget), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(Gadget), #GWL_EXSTYLE) | #WS_EX_TRANSPARENT)
If IsDarkColorOC(TextColor) : SetGadgetColor(Gadget, #PB_Gadget_FrontColor, $909090) : Else : SetGadgetColor(Gadget, #PB_Gadget_FrontColor, $707070) : EndIf
EndIf
ProcedureReturn #False
Case #WM_ERASEBKGND
;PushMapPosition(ObjectC())
If FindMapElement(ObjectC(), Str(Gadget))
If Not(\BackMode = #PB_Default And \TextMode = #PB_Default)
BackColor = \BackColor
Found = #True
EndIf
EndIf
;PopMapPosition(ObjectC())
If Found = #False Or BackColor = #PB_None : ProcedureReturn Result : EndIf
CompilerIf #EditAccentColor
If IsDarkColorOC(BackColor) : BackColor = AccentColorOC(BackColor, 10) : Else : BackColor = AccentColorOC(BackColor, -10) : EndIf
CompilerEndIf
If #DebugON : Debug LSet(GadgetTypeToString(Gadget) + ": ", 22) + LSet(Str(Gadget), 10) + " - Back RGB(" + Str(Red(BackColor)) + ", " + Str(Green(BackColor)) + ", " + Str(Blue(BackColor)) + ")" : EndIf
GetClientRect_(hWnd, Rect)
If Not(FindMapElement(ObjectCBrush(), Str(BackColor)))
ObjectCBrush(Str(BackColor)) = CreateSolidBrush_(BackColor)
EndIf
FillRect_(wParam, @Rect, ObjectCBrush(Str(BackColor)))
ProcedureReturn #True
EndSelect
EndWith
ProcedureReturn Result
EndProcedure
Procedure WinCallback(hWnd, uMsg, wParam, lParam)
Protected Result = #PB_ProcessPureBasicEvents
Protected Gadget, ParentGadget, Buffer.s, Text.s, BackColor, TextColor, Color_HightLight, FadeGrayColor, Found, I
Protected *NMDATETIMECHANGE.NMDATETIMECHANGE, *DrawItem.DRAWITEMSTRUCT, *lvCD.NMLVCUSTOMDRAW
With ObjectC()
Select uMsg
Case #WM_CLOSE
PostEvent(#PB_Event_Gadget, GetDlgCtrlID_(hWnd), 0, #PB_Event_CloseWindow) ; Required to manage it with #PB_Event_CloseWindow event, if the window is minimized and closed from the taskbar (Right CLick)
Case #WM_NCDESTROY
; Delete map element for all children's gadgets that no longer exist after CloseWindow(). Useful in case of multiple windows
If MapSize(ObjectC()) > 0
ResetMap(ObjectC())
While NextMapElement(ObjectC())
If Not(IsGadget(Val(MapKey(ObjectC()))))
If \OldProc
SetWindowLongPtr_(\ObjectID, #GWLP_WNDPROC, \OldProc)
EndIf
DeleteMapElement(ObjectC())
EndIf
Wend
EndIf
; Delete all brushes and map element. If there are used brushes in other windows, they will be recreated
If MapSize(ObjectCBrush()) > 0
ResetMap(ObjectCBrush())
While NextMapElement(ObjectCBrush())
DeleteObject_(ObjectCBrush())
DeleteMapElement(ObjectCBrush())
Wend
EndIf
;ProcedureReturn #False