Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi TListview und Bitmaps neuzeichen (https://www.delphipraxis.net/106791-tlistview-und-bitmaps-neuzeichen.html)

Jens Schumann 16. Jan 2008 19:21


TListview und Bitmaps neuzeichen
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo,
in einer SubItemspalte (Bewertung) eines TListview zeige ich in Abhängigkeit eines
numerischen Wertes eine Bitmap an. Damit ich an den SubItemIndex komme
passiert das im OnAdvancedCustomDrawSubItem Ereignis.

Delphi-Quellcode:
procedure TFormDoubleSongDialog.lvDatabaseAdvancedCustomDrawSubItem(
  Sender: TCustomListView; Item: TListItem; SubItem: Integer;
  State: TCustomDrawState; Stage: TCustomDrawStage;
  var DefaultDraw: Boolean);
var
  SubItemLeft : Integer;
  CheckSong  : TCheckSongItem;
  iCnt       : Integer;
begin
  If (Item=nil) then
    Exit;
  // Berechne die Left-Koordinate des passenden Items
  CheckSong:=TCheckSongItem(Item.Data);
  If (CheckSong<>Nil) and (SubItem=5) and (Stage=cdPrePaint) then // mit Stage=cdPrePaint entspricht das Event dem OnDrawSubItem
    begin
    SubItemLeft:=Item.Left;
    For iCnt:=0 to TListView(Sender).Columns.Count-2 do // Berechne die Left-Koordiante für das Bitmap
      Inc(SubItemLeft,Sender.Column[iCnt].Width);
    Try
      Sender.Canvas.Draw(SubItemLeft,Item.Top,SystemDataprovider.Stars.Value[CheckSong.Rating].Bitmap);
    Except
      Sender.Canvas.Draw(SubItemLeft,Item.Top,SystemDataprovider.Stars.Value[0].Bitmap);
      end;
    end; // If SubItem=5 then
end;
Beim vergrößern der linken Nachbarspalte werden die Bitmaps scheinbar 2mal gezeichnet. Einmal an
der alten und einmal an der neuen Position. (Siehe Anlage)
Wie erreiche ich es, dass die Bitmaps nur an der neuen Position gezeichnet werden?


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:28 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz