-
Notifications
You must be signed in to change notification settings - Fork 1
/
TFlatColorComboBoxUnit.pas
697 lines (647 loc) · 19.3 KB
/
TFlatColorComboBoxUnit.pas
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
unit TFlatColorComboBoxUnit;
{***************************************************************}
{ TFlatColorComboBox }
{ Copyright ©1999 Lloyd Kinsella. }
{ }
{ FlatStyle is Copyright ©1998-99 Maik Porkert. }
{***************************************************************}
interface
{$I DFS.inc}
uses
Windows, Messages, Classes, Forms, Controls, Graphics, StdCtrls, FlatUtilitys,
SysUtils, ShellApi, CommCtrl, Consts, Dialogs;
type
TFlatColorComboBox = class(TCustomComboBox)
private
FArrowColor: TColor;
FArrowBackgroundColor: TColor;
FBorderColor: TColor;
FHighlightColor: TColor;
FUseAdvColors: Boolean;
FAdvColorArrowBackground: TAdvColors;
FAdvColorBorder: TAdvColors;
FAdvColorHighlight: TAdvColors;
FButtonWidth: Integer;
FChildHandle: HWND;
FDefListProc: Pointer;
FListHandle: HWND;
FListInstance: Pointer;
FSysBtnWidth: Integer;
FSolidBorder: Boolean;
FShowNames: Boolean;
FValue: TColor;
FColorBoxWidth: Integer;
FColorDlg: TColorDialog;
procedure SetColors (Index: Integer; Value: TColor);
procedure SetAdvColors (Index: Integer; Value: TAdvColors);
procedure SetUseAdvColors (Value: Boolean);
function GetButtonRect: TRect;
procedure PaintButton;
procedure PaintBorder;
procedure RedrawBorders;
procedure InvalidateSelection;
function GetSolidBorder: Boolean;
procedure SetSolidBorder;
procedure ListWndProc (var Message: TMessage);
procedure WMSetFocus (var Message: TMessage); message WM_SETFOCUS;
procedure WMKillFocus (var Message: TMessage); message WM_KILLFOCUS;
procedure WMKeyDown (var Message: TMessage); message WM_KEYDOWN;
procedure WMPaint (var Message: TWMPaint); message WM_PAINT;
procedure WMNCPaint (var Message: TMessage); message WM_NCPAINT;
procedure CMEnabledChanged (var Msg: TMessage); message CM_ENABLEDCHANGED;
procedure CNCommand (var Message: TWMCommand); message CN_COMMAND;
procedure CMFontChanged (var Message: TMessage); message CM_FONTCHANGED;
procedure CMSysColorChange (var Message: TMessage); message CM_SYSCOLORCHANGE;
procedure CMParentColorChanged (var Message: TWMNoParams); message CM_PARENTCOLORCHANGED;
procedure SetShowNames(Value: Boolean);
procedure SetColorValue(Value: TColor);
procedure SetColorBoxWidth(Value: Integer);
protected
procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
procedure CreateWnd; override;
procedure WndProc (var Message: TMessage); override;
procedure ComboWndProc (var Message: TMessage; ComboWnd: HWnd; ComboProc: Pointer); override;
procedure CalcAdvColors;
property SolidBorder: Boolean read FSolidBorder;
procedure Click; override;
public
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
function AddColor(ColorName: String; Color: TColor): Boolean;
function DeleteColorByName(ColorName: String): Boolean;
function DeleteColorByColor(Color: TColor): Boolean;
published
property Color default $00E1EAEB;
property ColorArrow: TColor index 0 read FArrowColor write SetColors default clBlack;
property ColorArrowBackground: TColor index 1 read FArrowBackgroundColor write SetColors default $00C5D6D9;
property ColorBorder: TColor index 2 read FBorderColor write SetColors default $008396A0;
property ColorHighlight: TColor index 3 read FHighlightColor write SetColors default clHighlight;
property AdvColorBorder: TAdvColors index 0 read FAdvColorBorder write SetAdvColors default 50;
property AdvColorArrowBackground: TAdvColors index 1 read FAdvColorArrowBackground write SetAdvColors default 10;
property AdvColorHighlight: TAdvColors index 2 read FAdvColorHighlight write SetAdvColors default 50;
property UseAdvColors: Boolean read FUseAdvColors write SetUseAdvColors default False;
property BoxWidth: Integer read FColorBoxWidth write SetColorBoxWidth;
property ShowNames: Boolean read FShowNames write SetShowNames;
property Value: TColor read FValue write SetColorValue;
property DragMode;
property DragCursor;
property DropDownCount;
property Enabled;
property Font;
property MaxLength;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Sorted;
property TabOrder;
property TabStop;
property Visible;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnDropDown;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMeasureItem;
property OnStartDrag;
{$IFDEF DFS_DELPHI_4_UP}
property Anchors;
property BiDiMode;
property Constraints;
property DragKind;
property ParentBiDiMode;
property OnEndDock;
property OnStartDock;
{$ENDIF}
end;
implementation
const
StdColors = 16;
StdColorValues: array [1..StdColors] of TColor = (
clBlack, clMaroon, clGreen, clOlive, clNavy, clPurple, clTeal, clGray,
clSilver, clRed, clLime, clYellow, clBlue, clFuchsia, clAqua, clWhite);
constructor TFlatColorComboBox.Create (AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle - [csFixedHeight] + [csOpaque];
TControlCanvas(Canvas).Control := Self;
Style := csOwnerDrawFixed;
FButtonWidth := 11;
FSysBtnWidth := GetSystemMetrics(SM_CXVSCROLL);
FListInstance := MakeObjectInstance(ListWndProc);
FDefListProc := nil;
FArrowColor := clBlack;
FArrowBackgroundColor := $00C5D6D9;
FBorderColor := $008396A0;
FHighlightColor := clHighlight;
FUseAdvColors := False;
FAdvColorBorder := 50;
FAdvColorArrowBackground := 10;
FAdvColorHighlight := 30;
FShowNames := True;
FColorBoxWidth := 12;
FValue := clBlack;
FColorDlg := TColorDialog.Create(Self);
end;
destructor TFlatColorComboBox.Destroy;
begin
FColorDlg.Free;
FreeObjectInstance(FListInstance);
inherited;
end;
procedure TFlatColorComboBox.CreateWnd;
var
I: Integer;
ColorName: string;
begin
inherited CreateWnd;
Clear;
for I := 1 to StdColors do
begin
ColorName := Copy(ColorToString(StdColorValues[I]), 3, 40);
Items.AddObject(ColorName, TObject(StdColorValues[I]));
end;
Items.AddObject('Custom',TObject(clBlack));
ItemIndex := 0;
Change;
end;
procedure TFlatColorComboBox.SetColors (Index: Integer; Value: TColor);
begin
case Index of
0: FArrowColor := Value;
1: FArrowBackgroundColor := Value;
2: FBorderColor := Value;
3: FHighlightColor := Value;
end;
Invalidate;
end;
procedure TFlatColorComboBox.CalcAdvColors;
begin
if FUseAdvColors then
begin
FBorderColor := CalcAdvancedColor(TForm(Parent).Color, FBorderColor, FAdvColorBorder, darken);
FArrowBackgroundColor := CalcAdvancedColor(TForm(Parent).Color, FArrowBackgroundColor, FAdvColorArrowBackground, darken);
FHighlightColor := CalcAdvancedColor(TForm(Parent).Color, FHighlightColor, FAdvColorHighlight, darken);
end;
end;
procedure TFlatColorComboBox.SetAdvColors (Index: Integer; Value: TAdvColors);
begin
case Index of
0: FAdvColorBorder := Value;
1: FAdvColorArrowBackground := Value;
2: FAdvColorHighlight := Value;
end;
CalcAdvColors;
Invalidate;
end;
procedure TFlatColorComboBox.SetUseAdvColors(Value: Boolean);
begin
if Value <> FUseAdvColors then
begin
FUseAdvColors := Value;
CalcAdvColors;
Invalidate;
end;
end;
procedure TFlatColorComboBox.CMSysColorChange (var Message: TMessage);
begin
if FUseAdvColors then
CalcAdvColors;
Invalidate;
end;
procedure TFlatColorComboBox.CMParentColorChanged (var Message: TWMNoParams);
begin
if FUseAdvColors then
CalcAdvColors;
Invalidate;
end;
procedure TFlatColorComboBox.WndProc (var Message: TMessage);
begin
if (Message.Msg = WM_PARENTNOTIFY) then
case LoWord(Message.wParam) of
WM_CREATE:
if FDefListProc <> nil then
begin
SetWindowLong(FListHandle, GWL_WNDPROC, Longint(FDefListProc));
FDefListProc := nil;
FChildHandle := Message.lParam;
end
else
if FChildHandle = 0 then
FChildHandle := Message.lParam
else
FListHandle := Message.lParam;
end
else
if (Message.Msg = WM_WINDOWPOSCHANGING) then
if Style in [csDropDown, csSimple] then
SetWindowPos( EditHandle, 0,
0, 0, ClientWidth - FButtonWidth - 2 * 2 - 4, Height - 2 * 2 - 2,
SWP_NOMOVE + SWP_NOZORDER + SWP_NOACTIVATE + SWP_NOREDRAW);
inherited;
if Message.Msg = WM_CTLCOLORLISTBOX then
begin
SetBkColor(Message.wParam, ColorToRGB(Color));
Message.Result := CreateSolidBrush(ColorToRGB(Color));
end;
end;
procedure TFlatColorComboBox.ListWndProc (var Message: TMessage);
begin
case Message.Msg of
WM_WINDOWPOSCHANGING:
with TWMWindowPosMsg(Message).WindowPos^ do
begin
// size of the drop down list
if Style in [csDropDown, csDropDownList] then
cy := (GetFontHeight(Font)-2) * Min(DropDownCount, Items.Count) + 4
else
cy := (ItemHeight) * Min(DropDownCount, Items.Count) + 4;
if cy <= 4 then
cy := 10;
end;
else
with Message do
Result := CallWindowProc(FDefListProc, FListHandle, Msg, WParam, LParam);
end;
end;
procedure TFlatColorComboBox.ComboWndProc (var Message: TMessage; ComboWnd: HWnd; ComboProc: Pointer);
begin
inherited;
if (ComboWnd = EditHandle) then
case Message.Msg of
WM_SETFOCUS, WM_KILLFOCUS:
SetSolidBorder;
end;
end;
procedure TFlatColorComboBox.WMSetFocus (var Message: TMessage);
begin
inherited;
if not (csDesigning in ComponentState) then
begin
SetSolidBorder;
if not (Style in [csSimple, csDropDown]) then
InvalidateSelection;
end;
end;
procedure TFlatColorComboBox.WMKillFocus (var Message: TMessage);
begin
inherited;
if not (csDesigning in ComponentState) then
begin
SetSolidBorder;
if not (Style in [csSimple, csDropDown]) then
InvalidateSelection;
end;
end;
procedure TFlatColorComboBox.CMEnabledChanged (var Msg: TMessage);
begin
inherited;
Invalidate;
end;
procedure TFlatColorComboBox.CNCommand (var Message: TWMCommand);
var
R: TRect;
begin
inherited;
if Message.NotifyCode in [1, 9, CBN_DROPDOWN, CBN_SELCHANGE] then
begin
if not (Style in [csSimple, csDropDown]) then
InvalidateSelection;
end;
if (Message.NotifyCode in [CBN_CLOSEUP]) then
begin
R := GetButtonRect;
Dec(R.Left, 2);
InvalidateRect(Handle, @R, FALSE);
end;
end;
procedure TFlatColorComboBox.WMKeyDown (var Message: TMessage);
var
S: String;
begin
S := Text;
inherited;
if not (Style in [csSimple, csDropDown]) and (Text <> S) then
InvalidateSelection;
end;
procedure TFlatColorComboBox.WMPaint (var Message: TWMPaint);
var
R: TRect;
DC: HDC;
PS: TPaintStruct;
begin
DC := BeginPaint(Handle, PS);
try
R := PS.rcPaint;
if R.Right > Width - FButtonWidth - 4 then
R.Right := Width - FButtonWidth - 4;
FillRect(DC, R, Brush.Handle);
if RectInRect(GetButtonRect, PS.rcPaint) then
PaintButton;
ExcludeClipRect(DC, ClientWidth - FSysBtnWidth - 2, 0, ClientWidth, ClientHeight);
PaintWindow(DC);
if (Style = csDropDown) and DroppedDown then
begin
R := ClientRect;
InflateRect(R, -2, -2);
R.Right := Width - FButtonWidth - 3;
Canvas.Brush.Color := clWindow;
Canvas.FrameRect(R);
end
else
if Style <> csDropDown then
InvalidateSelection;
finally
EndPaint(Handle, PS);
end;
RedrawBorders;
Message.Result := 0;
end;
procedure TFlatColorComboBox.WMNCPaint (var Message: TMessage);
begin
inherited;
RedrawBorders;
end;
procedure TFlatColorComboBox.CMFontChanged (var Message: TMessage);
begin
inherited;
ItemHeight := 13;
RecreateWnd;
end;
procedure TFlatColorComboBox.InvalidateSelection;
var
R: TRect;
begin
R := ClientRect;
InflateRect(R, -2, -3);
R.Left := R.Right - FButtonWidth - 8;
Dec(R.Right, FButtonWidth + 3);
if (GetFocus = Handle) and not DroppedDown then
Canvas.Brush.Color := FHighLightcolor
else
Canvas.Brush.Color := Color;
Canvas.Brush.Style := bsSolid;
Canvas.FillRect(R);
if (GetFocus = Handle) and not DroppedDown then
begin
R := ClientRect;
InflateRect(R, -3, -3);
Dec(R.Right, FButtonWidth + 2);
Canvas.FrameRect(R);
Canvas.Brush.Color := clWindow;
end;
ExcludeClipRect(Canvas.Handle, ClientWidth - FSysBtnWidth - 2, 0, ClientWidth, ClientHeight);
end;
function TFlatColorComboBox.GetButtonRect: TRect;
begin
GetWindowRect(Handle, Result);
OffsetRect(Result, -Result.Left, -Result.Top);
Inc(Result.Left, ClientWidth - FButtonWidth);
OffsetRect(Result, -1, 0);
end;
procedure TFlatColorComboBox.PaintButton;
var
R: TRect;
x, y: Integer;
begin
R := GetButtonRect;
InflateRect(R, 1, 0);
Canvas.Brush.Color := FArrowBackgroundColor;
Canvas.FillRect(R);
Canvas.Brush.Color := FBorderColor;
Canvas.FrameRect(R);
x := (R.Right - R.Left) div 2 - 6 + R.Left;
if DroppedDown then
y := (R.Bottom - R.Top) div 2 - 1 + R.Top
else
y := (R.Bottom - R.Top) div 2 - 1 + R.Top;
if Enabled then
begin
canvas.Brush.Color := FArrowColor;
canvas.Pen.Color := FArrowColor;
if DroppedDown then
canvas.Polygon([Point(x + 4, y + 2), Point(x + 8, y + 2), Point(x + 6, y)])
else
canvas.Polygon([Point(x + 4, y), Point(x + 8, y), Point(x + 6, y + 2)]);
end
else
begin
canvas.Brush.Color := clWhite;
canvas.Pen.Color := clWhite;
Inc(x); Inc(y);
if DroppedDown then
canvas.Polygon([Point(x + 4, y + 2), Point(x + 8, y + 2), Point(x + 6, y)])
else
canvas.Polygon([Point(x + 4, y), Point(x + 8, y), Point(x + 6, y + 2)]);
Dec(x); Dec(y);
canvas.Brush.Color := clGray;
canvas.Pen.Color := clGray;
if DroppedDown then
canvas.Polygon([Point(x + 4, y + 2), Point(x + 8, y + 2), Point(x + 6, y)])
else
canvas.Polygon([Point(x + 4, y), Point(x + 8, y), Point(x + 6, y + 2)]);
end;
ExcludeClipRect(Canvas.Handle, ClientWidth - FSysBtnWidth, 0, ClientWidth, ClientHeight);
end;
procedure TFlatColorComboBox.PaintBorder;
var
DC: HDC;
R: TRect;
BtnFaceBrush, WindowBrush: HBRUSH;
begin
DC := GetWindowDC(Handle);
GetWindowRect(Handle, R);
OffsetRect(R, -R.Left, -R.Top);
Dec(R.Right, FButtonWidth + 1);
try
BtnFaceBrush := CreateSolidBrush(ColorToRGB(FBorderColor));
WindowBrush := CreateSolidBrush(ColorToRGB(Color));
FrameRect(DC, R, BtnFaceBrush);
InflateRect(R, -1, -1);
FrameRect(DC, R, WindowBrush);
InflateRect(R, -1, -1);
FrameRect(DC, R, WindowBrush);
finally
ReleaseDC(Handle, DC);
end;
DeleteObject(WindowBrush);
DeleteObject(BtnFaceBrush);
end;
function TFlatColorComboBox.GetSolidBorder: Boolean;
begin
Result := ( (csDesigning in ComponentState) and Enabled) or
(not(csDesigning in ComponentState) and
(DroppedDown or (GetFocus = Handle) or (GetFocus = EditHandle)) );
end;
procedure TFlatColorComboBox.SetSolidBorder;
var
sb: Boolean;
begin
sb := GetSolidBorder;
if sb <> FSolidBorder then
begin
FSolidBorder := sb;
RedrawBorders;
end;
end;
procedure TFlatColorComboBox.RedrawBorders;
begin
PaintBorder;
if Style <> csSimple then PaintButton;
end;
procedure TFlatColorComboBox.SetShowNames(Value: Boolean);
begin
if Value <> FShowNames then
begin
FShowNames := Value;
Invalidate;
end;
end;
procedure TFlatColorComboBox.SetColorValue(Value: TColor);
var
Item: Integer;
CurrentColor: TColor;
begin
if (ItemIndex < 0) or (Value <> FValue) then
begin
for Item := 0 to Pred(Items.Count) do
begin
CurrentColor := TColor(Items.Objects[Item]);
if CurrentColor = Value then
begin
FValue := Value;
if ItemIndex <> Item then ItemIndex := Item;
Change;
Break;
end;
end;
end;
end;
procedure TFlatColorComboBox.SetColorBoxWidth(Value: Integer);
begin
if Value <> FColorBoxWidth then
begin
FColorBoxWidth := Value;
end;
Invalidate;
end;
procedure TFlatColorComboBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
ARect: TRect;
Text: array[0..255] of Char;
Safer: TColor;
begin
ARect := Rect;
Inc(ARect.Top, 2);
Dec(ARect.Bottom, 2);
Inc(ARect.Left, 2);
Dec(ARect.Right, 2);
if FShowNames then
begin
ARect.Right := ARect.Left + FColorBoxWidth;
end
else
begin
Dec(ARect.Right, 3);
end;
with Canvas do
begin
Safer := Brush.Color;
if (odSelected in State) then
begin
Canvas.Brush.Color := FHighlightColor;
FillRect(Rect);
Pen.Color := clBlack;
Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
end
else
begin
Canvas.Brush.Color := Color;
FillRect(Rect);
Pen.Color := clBlack;
Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
end;
Brush.Color := ColorToRgb(TColor(Items.Objects[Index]));
try
InflateRect(ARect, -1, -1);
FillRect(ARect)
finally
Brush.Color := Safer;
end;
if FShowNames then
begin
StrPCopy(Text, Items[Index]);
Rect.Left := ARect.Right + 5;
Brush.Style := bsClear;
DrawText(Canvas.Handle, Text, StrLen(Text), Rect, DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX);
Brush.Style := bsSolid;
end;
end;
end;
procedure TFlatColorComboBox.Click;
begin
if ItemIndex >= 0 then
begin
if Items[ItemIndex] = 'Custom' then
begin
if not FColorDlg.Execute then
Exit;
Items.Objects[ItemIndex] := TObject(FColorDlg.Color);
end;
Value := TColor(Items.Objects[ItemIndex]);
end;
inherited Click;
end;
function TFlatColorComboBox.AddColor(ColorName: String; Color: TColor): Boolean;
var
I: Integer;
begin
for I := 0 to Items.Count - 1 do
begin
if UpperCase(ColorName) = UpperCase(Items[I]) then
begin
Result := False;
Exit;
end;
end;
Items.InsertObject(Items.Count - 1, ColorName, TObject(Color));
Result := True;
end;
function TFlatColorComboBox.DeleteColorByName(ColorName: String): Boolean;
var
I: Integer;
begin
for I := 0 to Items.Count - 1 do
begin
if UpperCase(ColorName) = UpperCase(Items[I]) then
begin
Items.Delete(I);
Result := True;
Exit;
end;
end;
Result := False;
end;
function TFlatColorComboBox.DeleteColorByColor(Color: TColor): Boolean;
var
I: Integer;
begin
for I := 0 to Items.Count - 1 do
begin
if Color = TColor(Items.Objects[I]) then
begin
Items.Delete(I);
Result := True;
Exit;
end;
end;
Result := False;
end;
end.