procedure TForm1.CheckListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var TempColor: TColor; begin if odFocused in State then begin CheckListBox1.Canvas.Brush.Color := clHighlight; TempColor := clRed; end else begin CheckListBox1.Canvas.Brush.Color := CheckListBox1.Color; TempColor := clBlack; end; CheckListBox1.Canvas.FillRect(Rect); CheckListBox1.Canvas.Font.Color := TempColor; CheckListBox1.Canvas.TextOut(Rect.Left, Rect.Top, CheckListBox1.Items[Index]); end;procedure TForm1.CheckListBox1MeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); begin Height := 18; end;procedure TForm1.FormCreate(Sender: TObject); begin with CheckListBox1 do begin Style := lbOwnerDrawVariable; Items.Add('aaaaaaaa'); Items.Add('bbbbbbbb'); end; end;
OnDrawItem
OnMeasureItem
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
TempColor: TColor;
begin
if odFocused in State then begin
CheckListBox1.Canvas.Brush.Color := clHighlight;
TempColor := clRed;
end else begin
CheckListBox1.Canvas.Brush.Color := CheckListBox1.Color;
TempColor := clBlack;
end; CheckListBox1.Canvas.FillRect(Rect); CheckListBox1.Canvas.Font.Color := TempColor;
CheckListBox1.Canvas.TextOut(Rect.Left, Rect.Top, CheckListBox1.Items[Index]);
end;procedure TForm1.CheckListBox1MeasureItem(Control: TWinControl;
Index: Integer; var Height: Integer);
begin
Height := 18;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
with CheckListBox1 do begin
Style := lbOwnerDrawVariable;
Items.Add('aaaaaaaa');
Items.Add('bbbbbbbb');
end;
end;