![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
как в TlistBox изменить цвет полоски выделеного item-а? [D6, WinXP]
k-sergey © (2004-08-20 10:55:00)как в TlistBox изменить цвет полоски выделеного item-а?
Анонимщик (2004-08-25 12:10:00) [1]Исходники нашел? Теперь пойми логику и не доставай.
k-sergey (2004-08-21 21:23:00) [2]все ничего но полоска выделения не ровная...
это хорошо заметно на букве - д, в низу. :-\
k-sergey (2004-08-21 20:53:00) [3]во, все спасобо еще раз, нашел, блин я просто не подумал что это оно/
k-sergey (2004-08-21 20:51:00) [4]спасибо.
А в каком исходнике? (хоть знать буду :-) )
ясно понятно что все должно быть так же как у ListBox
но что то найти это у меня не получилось.
Анонимщик (2004-08-21 12:36:00) [5]В исходники облом посмотреть? Вот тебе:
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 11:37:00) [6]А что можно сделать если вместо Listbox использую FileListBox
там нет этого свойства?
k-sergey (2004-08-20 13:03:00) [7]ага спасибо большое.
Анонимщик (2004-08-20 13:01:00) [8]В обработчике 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 12:33:00) [9]это я в справке видал...если бы все понял то не спрашивал бы.
Анонимщик (2004-08-20 12:12:00) [10]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.