Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi VirtualStringTree (VST) und Progressbar einbinden (https://www.delphipraxis.net/133149-virtualstringtree-vst-und-progressbar-einbinden.html)

MCXSC 26. Apr 2009 23:19


VirtualStringTree (VST) und Progressbar einbinden
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo,

ich arbeite mit der VirtualStringTree (VST) von M. Lischke und habe nun folgendes Problem:

Und zwar versuche ich derzeit, in einer Zelle eine Art Progressbar einzubauen (siehe Bild). Allerdings scheitern meine Versuche bereits irgendwie im Ansatz. Hat jemand einen kleinen Tipp bzw. ein kleines Tutorial dazu?

Danke,
MCXSC

Mithrandir 26. Apr 2009 23:29

Re: VirtualStringTree (VST) und Progressbar einbinden
 
Ich kann dir verraten, wie man eine TProgressBar in eine TStatusBar bekommt. Ich vermute mal, dass sich die beiden Lösungsansätze nur im Ereignis unterscheiden, das benutzt wird.

chaosben 27. Apr 2009 07:27

Re: VirtualStringTree (VST) und Progressbar einbinden
 
Liste der Anhänge anzeigen (Anzahl: 1)
Das einfachste ist eine selbstgeschriebene OnAfterCellPaint à la:
Delphi-Quellcode:
var
  NData : PNodeData;
  PBRect : TRect;
  Text : String;
begin
  if Column = 1 then
  begin
    if GetNodeData(Node, NData) then
    begin
      PBRect := Rect(CellRect.Left + 1,
                     CellRect.Top + 1,
                     CellRect.Left + Round((CellRect.Right - CellRect.Left - 2) * (NData.Percent / 100)),
                     CellRect.Bottom - 1);

      with TargetCanvas do
      begin
        Pen.Color := RGB(226, 194, 95);
        Pen.Style := psSolid;
        Brush.Style := bsClear;
        Rectangle(PBRect);

        Brush.Color := RGB(246, 224, 123);
        Brush.Style := bsSolid;
        FillRect(Rect(PBRect.Left + 2,
                      PBRect.Top + 2,
                      PBRect.Right - 2,
                      PBRect.Bottom - 2));

        Text := Format('%d %%', [NData.Percent]);
        Font.Color := clBlack;
        Brush.Style := bsClear;

        TextOut(CellRect.Left + ((CellRect.Right - CellRect.Left) div 2) - (TextWidth(Text) div 2),
                CellRect.Top + ((CellRect.Bottom - CellRect.Top) div 2) - (TextHeight(Text) div 2),
                Text);

      end;
    end;
  end;
end;

MCXSC 27. Apr 2009 12:59

Re: VirtualStringTree (VST) und Progressbar einbinden
 
Super, vielen Dank! :bouncing4:

MCXSC 27. Apr 2009 20:49

Re: VirtualStringTree (VST) und Progressbar einbinden
 
Eine Frage habe ich dann doch noch:

Und zwar werden die Prozentzahlen bei mir nur in einem sehr hellen grau angezeigt. Eine Idee?

Ich habe auch schon folgendes versucht:

Delphi-Quellcode:
[...]
  Pen.Color := clBlack;
  Brush.Style := bsClear;
[...]

chaosben 28. Apr 2009 05:35

Re: VirtualStringTree (VST) und Progressbar einbinden
 
Ja, sorry ... mein Fehler.
Natürlich muss man vor dem TextOut nicht dem Pen sondern dem Font die Farbe zuweisen.

Delphi-Quellcode:
Text := Format('%d %%', [NData.Percent]);
Font.Color := clBlue; //<----- hier
Brush.Style := bsClear;

TextOut(CellRect.Left + ((CellRect.Right - CellRect.Left) div 2) - (TextWidth(Text) div 2),
        CellRect.Top + ((CellRect.Bottom - CellRect.Top) div 2) - (TextHeight(Text) div 2),
        Text);

MCXSC 28. Apr 2009 16:43

Re: VirtualStringTree (VST) und Progressbar einbinden
 
Hm, hätte ich auch drauf kommen können.^^

Nur was ich merkwürdig finde: So klappt es, aber in deiner Demo hast du eben dieses "Pen.Color" verwendet (eben auch am Ende) und da klappt es auch...

chaosben 28. Apr 2009 19:39

Re: VirtualStringTree (VST) und Progressbar einbinden
 
Ja, das es in der Demo klappt ist Zufall. :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:19 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