AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Delphi Hintergrund in Listview einfärben
Thema durchsuchen
Ansicht
Themen-Optionen

Hintergrund in Listview einfärben

Ein Thema von Puke · begonnen am 13. Nov 2012 · letzter Beitrag vom 27. Nov 2012
 
Benutzerbild von Puke
Puke

Registriert seit: 7. Nov 2012
123 Beiträge
 
Delphi XE5 Architect
 
#8

AW: Hintergrund in Listview einfärben

  Alt 27. Nov 2012, 08:32
Ich schreibe mal für andere mit gleichem Problem, eine weniger elegante Lösung hier auf:

Wenn man das Problem hat, dass die Hintergrundfarbe nachdem Text aufhört, verlängeret man einfach den Text bis zur Ende der Coloumn mit Leerzeichen,
benutzt aber nicht mehr.

Delphi-Quellcode:
procedure TForm1.PlaylistViewCustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var
  hallo:TLIstItem;
  weite : Integer;
  längederliste: Integer;
begin
if Fertig=true
then begin

  defaultDraw:=false;


  //Titel
  weite:= playlistview.Columns[0].Width;
  testlabel.Caption:= item.Caption;
  while testlabel.Width<weite+5 do
  begin
    Testlabel.Caption:=testlabel.caption+DupeString(' ', 1);
  end;
  item.Caption:=testlabel.Caption;

  if Anpassen=true
  then begin

    längederliste:= playlistview.Items.Count;

    //Interpret
    weite:= playlistview.Columns[1].Width;
    testlabel.Caption:= item.SubItems[0];
    while testlabel.Width<weite+5 do
    begin
      Testlabel.Caption:= testlabel.caption+DupeString(' ', 1);
    end;
    item.SubItems[0]:=testlabel.Caption;

    //Album
    weite:= playlistview.Columns[2].Width;
    testlabel.Caption:= item.SubItems[1];
    while testlabel.Width<weite+5 do
    begin
      Testlabel.Caption:= testlabel.caption+DupeString(' ', 1);
    end;
    item.SubItems[1]:=testlabel.Caption;

    //Genre
    weite:= playlistview.Columns[3].Width;
    testlabel.Caption:= item.SubItems[2];
    while testlabel.Width<weite+5 do
    begin
      Testlabel.Caption:= testlabel.caption+DupeString(' ', 1);
    end;
    item.SubItems[2]:=testlabel.Caption;

    //Dauer
    weite:= playlistview.Columns[4].Width;
    testlabel.Caption:= item.SubItems[3];
    while testlabel.Width<weite+5 do
    begin
      Testlabel.Caption:= testlabel.caption+DupeString(' ', 1);
    end;
    item.SubItems[3]:=testlabel.Caption;

    //Bewertung
    weite:= playlistview.Columns[5].Width;
    testlabel.Caption:= item.SubItems[4];
    while testlabel.Width<weite+5 do
    begin
      Testlabel.Caption:= testlabel.caption+DupeString(' ', 1);
    end;
    item.SubItems[4]:=testlabel.Caption;

    //Pfad
    weite:= playlistview.Columns[6].Width;
    testlabel.Caption:= item.SubItems[5];
    while testlabel.Width<weite+5 do
    begin
      Testlabel.Caption:= testlabel.caption+DupeString(' ', 1);
    end;
    item.SubItems[5]:=testlabel.Caption;
    durchgänge:= durchgänge+1;

    if durchgänge=längederliste
    then begin
      durchgänge:=0;
      anpassen:= false;
    end;


  end;



    hallo:= PlaylistView.Items[Item.Index];
  if (Item=nil) then Exit;

  with Sender.Canvas.Brush do
    if Odd(Item.Index) then Color:=cl3dlight
                                                                                            else Color:=clWhite;
  with Sender.Canvas.Font do
    if (titelanzeige.Caption= hallo.Caption) and
        (interpretlabel.caption= Hallo.SubItems[0]) and
        (albumlabel.Caption= hallo.SubItems[1]) and
        (genrelabel.Caption= Hallo.SubItems[2]) then Style:=[fsbold]
                                                                                            else Style:=[];

  with Sender.Canvas.Brush do
    if hallo.Caption+Hallo.SubItems[0]+hallo.SubItems[1]+Hallo.SubItems[2]=Playlistindex then Color:= clwebdarkorange;

  //Text widerherstellen
  TextOutOnListview(Playlistview, Item.Index);

end;
Damit ist das Thema glaub ich beendet.
Gruß Puke
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:38 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz