Показать сообщение отдельно
  #4  
Старый 17.10.2008, 12:20
san-46 san-46 вне форума
Активный
 
Регистрация: 25.04.2008
Сообщения: 383
Репутация: 33
По умолчанию

Код:
  TForm1 = class(TForm)
  private
    ChangeColor : Boolean;
  public
  end;
....
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with (Control as TListBox).Canvas do begin
    if not (odSelected in State) then
      if ChangeColor and (Index in [3..5]) then
        Brush.Color := clSkyBlue
      else
        Brush.Color := clWhite;
      FillRect(Rect);
      TextOut(Rect.Left + 2, Rect.Top, (Control as TListBox).Items[Index])
   end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ChangeColor := not ChangeColor; //каждое нажатие на кнопку включае/выключает подсветку
  ListBox1.Invalidate;
end;
А без ListBox1DrawItem все равно не обойтись.
__________________
Не забывайте делать резервные копии
Ответить с цитированием