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:
| const FarbArray : array [0..15] of TColor = (clBlack,clMaroon, clGreen, clOlive, clNavy, clPurple, clTeal, clGray, clSilver, clRed, clLime, clYellow, clBlue, clFuchsia, clAqua, clWhite);
procedure TForm10.ColorBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); const cBrushColors: array [Boolean] of TColor = (clWindow, clHighlight); cPenColors: array [Boolean] of TColor = (clWindowText, clHighlightText); begin Assert(Control is TCombobox); with (Control as TComboBox).Canvas do begin Brush.Color:= cBrushColors[(OdSelected in State) or (OdFocused in State)]; FillRect(Rect);
Rect.Right:= 20; Textout(Rect.Right + 5, Rect.Top + 1, (Control as TComboBox).Items[Index]); InflateRect(Rect, 0, -2); OffsetRect(Rect, 2, 0); Brush.Style := bsClear; Brush.Color := FarbArray[Index]; Rectangle(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom); end; end; |