1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
| procedure TForm1.DrawListBoxZC(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); const Col1: array[Boolean] of TColor = ($00C7C7C7, $00C7C7C7); Col2: array[Boolean] of TColor = (clBlack, clBlack); var TopDif: Integer; begin with (Control as TListBox) do begin if odSelected in State then begin Canvas.Brush.Style := bsClear; Canvas.Font.Color := clCaptionText; end else begin Canvas.Brush.Color := Col1[Odd(Index)]; Canvas.Font.Color := Col2[(Control as TListBox).Enabled]; end; TopDif := (ItemHeight div 2) - (Canvas.TextHeight(#32) div 2); Canvas.TextRect(Rect, Rect.Left, Rect.Top + TopDif, Items[Index]); end; end; |