Вниз
Скачать: CL | DM;

как в TlistBox изменить цвет полоски выделеного item-а?   Найти похожие ветки 

 
k-sergey ©   (2004-08-20 10:55) [0]

как в TlistBox изменить цвет полоски выделеного item-а?


 
Анонимщик ©   (2004-08-20 12:12) [1]

OnDrawItem

Use OnDrawItem to write a handler for drawing of the items in list boxes with the Style values lbOwnerDrawFixed, lbOwnerDrawVariable, or lbVirtualOwnerDraw. OnDrawItem occurs when the list box needs to display an item. OnDrawItem occurs only for owner-draw list boxes.


 
k-sergey ©   (2004-08-20 12:33) [2]

это я в справке видал...если бы все понял то не спрашивал бы.


 
Анонимщик ©   (2004-08-20 13:01) [3]

В обработчике OnDrawItem:

 with ListBox1.Canvas do
 begin
   if (odSelected in State) then Brush.Color := clRed else Brush.Color := clWhite;
   Canvas.Brush.Style := bsSolid;
   FillRect(Rect);
   TextOut(Rect.Left + 2, Rect.Top, (Control as TListBox).Items[Index]);
 end;


 
k-sergey ©   (2004-08-20 13:03) [4]

ага спасибо большое.


 
k-sergey ©   (2004-08-21 11:37) [5]

А что можно сделать если вместо Listbox использую FileListBox
там нет этого свойства?


 
Анонимщик ©   (2004-08-21 12:36) [6]

В исходники облом посмотреть? Вот тебе:

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls, FileCtrl;

type
 TForm1 = class(TForm)
   procedure FormCreate(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

type
 TColorSelFileListBox = class(TFileListBox)
 private
   procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
                        end;

procedure TColorSelFileListBox.CNDrawItem(var Message: TWMDrawItem);
var
 State: TOwnerDrawState;
begin
 with Message.DrawItemStruct^ do
 begin
   State := TOwnerDrawState(LongRec(itemState).Lo);
   Canvas.Handle := hDC;
   Canvas.Font := Font;
   Canvas.Brush := Brush;
   if (Integer(itemID) >= 0) and (odSelected in State) then
   begin
     Canvas.Brush.Color := clRed;
     Canvas.Font.Color := clHighlightText
   end;
   if Integer(itemID) >= 0 then
     DrawItem(itemID, rcItem, State) else
     Canvas.FillRect(rcItem);
   if odFocused in State then DrawFocusRect(hDC, rcItem);
   Canvas.Handle := 0;
 end;
end;

var
 FileListBox1: TColorSelFileListBox;

procedure TForm1.FormCreate(Sender: TObject);
begin
 FileListBox1 := TColorSelFileListBox.Create(nil);
 FileListBox1.Parent := self;
end;

end.


 
k-sergey ©   (2004-08-21 20:51) [7]

спасибо.
А в каком исходнике? (хоть знать буду :-) )
ясно понятно что все должно быть так же как у ListBox
но что то найти это у меня не получилось.


 
k-sergey ©   (2004-08-21 20:53) [8]

во, все спасобо еще раз, нашел, блин я просто не подумал что это оно/


 
k-sergey ©   (2004-08-21 21:23) [9]

все ничего но полоска выделения не ровная...
это хорошо заметно на букве - д, в низу. :-\


 
Анонимщик ©   (2004-08-25 12:10) [10]

Исходники нашел? Теперь пойми логику и не доставай.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.47 MB
Время: 0.022 c
3-1098548785
Bend
2004-10-23 20:26
2004.11.21
Упаковка таблицы.


1-1099490129
Oleg_
2004-11-03 16:55
2004.11.21
ТЕКСТ НА РИСУНКЕ РЕЖЕТСЯ


3-1098189214
Григорьев Антон
2004-10-19 16:33
2004.11.21
Арифметическое И в Access


14-1099645029
WondeRu
2004-11-05 11:57
2004.11.21
Балаковская АЭС


1-1099584984
uses-mind.dll
2004-11-04 19:16
2004.11.21
уничтожение динамически созданных объектов




   Наверх