Показать сообщение отдельно
  #1  
Старый 10.07.2014, 15:07
Alexandr_17_10 Alexandr_17_10 вне форума
Прохожий
 
Регистрация: 17.06.2014
Сообщения: 27
Версия Delphi: Delphi 7, XE6
Репутация: 10
По умолчанию свой цвет выделния у компонентов Listbox и т.п

Собственно вопрос как сделать свою рамку выделения у listbox
Код:
procedure TMainApl.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  With (Control as TListBox) do begin
    if odSelected in State then
      if Index mod 2 = 0 then begin
        DrawFocusRect((Control as TListBox).Canvas.Handle, Rect);
        canvas.Pen.Width:=3;
        canvas.Pen.Color:=clblue;
        canvas.Brush.Color:=clred
      end else begin
        DrawFocusRect((Control as TListBox).Canvas.Handle, Rect);
        canvas.Pen.Width:=3;
        canvas.Pen.Color:=clblue;
        canvas.Brush.Color:=clyellow;
      end
    else begin
      canvas.Pen.Width:=0;
      canvas.Pen.Color:=color;
      canvas.Brush.Color:=color;
    end;
    canvas.FillRect(rect);
    DrawText(Canvas.Handle, PChar(Items[Index]), Length(Items[Index]), Rect,
     Control.DrawTextBiDiModeFlags(DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX));
  end;
end;
но при этом мое выделение дйствует только на четных числах а нужно чтобы действовало на всех
Ответить с цитированием