Registriert seit: 16. Feb 2004
Ort: ---
232 Beiträge
|
Re: Lösung TListview eigene Farbe andere Icons für Aktive It
4. Dez 2005, 15:53
die lösung war in der DP
ListView_GetSubItemRect(Sender.Handle, Item.Index, SubItem, LVIR_BOUNDS, @aTextRect);
Delphi-Quellcode:
uses CommCtrl
//------------------------------------------------------------------------------
procedure TfmVarZusStln.lvElementeCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var
aIconRect, aTextRect:TRect;
SubItem:Integer;
begin
if (Item.Index=TListView(Sender).ItemIndex) or (TListView(Sender).ItemFocused=Item) or (Item.selected) then
begin
DefaultDraw:=False;
aIconRect:=Item.DisplayRect(drBounds);
aTextRect:=Item.DisplayRect(drLabel);
if TListView(Sender).ViewStyle=vsIcon then
begin
with Sender do
begin
Canvas.Pen.Color := $008FC2B3;
Canvas.Brush.Color := $00CDEFE9;
Canvas.Rectangle(aTextRect);
Windows.DrawText(Canvas.Handle, @Item.Caption[1], Length(Item.Caption),
aTextRect, DT_EDITCONTROL+DT_CENTER+DT_WORDBREAK);
Canvas.Brush.Color:=$008FC2B3;
Canvas.FrameRect(aTextRect);
TListView(Sender).LargeImages.Draw(Canvas,aIconRect.Left+((aIconRect.Right-aIconRect.Left) div 2)-TListView(Sender).LargeImages.Width div 2
,aIconRect.Top+2,1);
end;
end;
if TListView(Sender).ViewStyle<>vsIcon then
begin
with Sender do
begin
Canvas.Pen.Color := $00CDEFE9;
Canvas.Brush.Color := $00CDEFE9;
Canvas.Rectangle(aTextRect);
aTextRect.Left:=aTextRect.Left+2;
Windows.DrawText(Canvas.Handle, @Item.Caption[1], Length(Item.Caption),
aTextRect, DT_VCENTER);
Canvas.Brush.Color:=$008FC2B3;
Canvas.FrameRect(aTextRect);
TListView(Sender).SmallImages.Draw(Canvas,aIconRect.Left+2
,aIconRect.Top,1);
//----------------------------------------------------------------------
//SubItems durchlaufen
for SubItem:=1 to Item.SubItems.Count do
begin
ListView_GetSubItemRect(Sender.Handle, Item.Index, SubItem, LVIR_BOUNDS, @aTextRect);
if TListView(Sender).ViewStyle=vsReport then
begin
with Sender do
begin
Canvas.Pen.Color := $00CDEFE9;
Canvas.Brush.Color := $00CDEFE9;
Canvas.Rectangle(Rect(aTextRect.Left+2,aTextRect.Top,aTextRect.Right,aTextRect.Bottom));
aTextRect.Left:=aTextRect.Left+2;
Windows.DrawText(Canvas.Handle, @Item.SubItems[SubItem-1][1], Length(Item.SubItems[SubItem-1]),
aTextRect, DT_VCENTER);
Canvas.Brush.Color:=$008FC2B3;
Canvas.FrameRect(aTextRect);
end;
end;
end;
//----------------------------------------------------------------------
end;
end;
end; //Aktives Item
end;
//------------------------------------------------------------------------------
da die routine im oncustomdrawsubitem nur funktionierte wenn ich im oncustomdrawitem das Defaultdraw auf true liess (was natürlich nicht geht) hab ich versucht alles im oncustomdrawitem zu zeichnen und das ging
|
|
Zitat
|