Autor Beitrag
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mi 22.09.04 15:17 
Hi.
Wie kann ich einen Text auf/in einer ProgressBar anzeigen?
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Mi 22.09.04 15:44 
Mit nem Label dass de drüber legst.

_________________
Ha! Es compiliert! Wir können ausliefern!
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Mi 22.09.04 15:46 
Das geht nicht! Man kann das Label nicht nach vornebringen!
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mi 22.09.04 15:46 
jupp.
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Mi 22.09.04 15:52 
Geht das mit Canvas?!
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Mi 22.09.04 15:55 
Mit nem Panel vor der Progressbar.

Brush.Style auf bsClear und neu zeichnen.

_________________
Ha! Es compiliert! Wir können ausliefern!
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mi 22.09.04 15:58 
Wie, neu zeichnen??
Mit FillRect?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 22.09.04 20:29 
Normalerweise beschrifte ich meine Progressbars mit nem Edding ...

Ansonsten probier ich öfters auch Update, Repaint und Invalidate aus ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Mi 22.09.04 21:55 
Möglich wäre ein Label in die Progressbar einzubauen. Da man kein Label über die ProgressBar legen kann, legt man es eben rein. Hier ein Beispiel:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
  with Label1 do
  begin
    Parent := ProgressBar1;  // hier Progressbar angeben
    Transparent := True;
    Alignment := taCenter;
    Layout := tlCenter;
    Align := alClient;
    Font.Style := [fsBold];
    Font.Color := clGreen;
  end;


Die ProgressBar und das Label sollte schon vorher existieren. Der Code verschiebt den Label dann in die Progressbar. Dann wird der Label Hintergrund durchsichtig gemacht und das Label so angeordnet, daß er permanent mittig in der ProgressBar bleibt. Dann wird der Font noch so verändert, daß besser lesbar ist.

_________________
Gruß
Martin
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Mi 22.09.04 22:40 
Alternativ kannst du dir auch eine eigene Komponente erstellen, bei der du das Zeichnen überschreibst und am Ende noch Text darauf malst.

Hier hab ich mal ein bisschen Quelltext, mit dem du Text auf die ProgressBar zeichnen kannst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
var
  hDC: THandle;
  R: TRect;
begin
  with ProgressBar1 do begin
    hDC := GetWindowDC(Handle);
    try
      if hDC <> 0 then begin
        R := ClientRect;
        SetBKMode(hDC, TRANSPARENT);
        SetTextColor(hDC, RGB(255255255));
        DrawText(hDC, 'TEST'4, R,
          DT_SINGLELINE or DT_VCENTER or DT_CENTER);
      end;
    finally
      ReleaseDC(Handle, hDC);
    end;
  end;
Gruß Hape

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Fr 15.10.04 19:12 
thx, hat geklappt. :)
rstaeker
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 94

WIN 2000
D6 Prof
BeitragVerfasst: Sa 26.02.05 21:54 
wulfskin hat folgendes geschrieben:
Alternativ kannst du dir auch eine eigene Komponente erstellen, bei der du das Zeichnen überschreibst und am Ende noch Text darauf malst.

Hier hab ich mal ein bisschen Quelltext, mit dem du Text auf die ProgressBar zeichnen kannst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
var
  hDC: THandle;
  R: TRect;
begin
  with ProgressBar1 do begin
    hDC := GetWindowDC(Handle);
    try
      if hDC <> 0 then begin
        R := ClientRect;
        SetBKMode(hDC, TRANSPARENT);
        SetTextColor(hDC, RGB(255255255));
        DrawText(hDC, 'TEST'4, R,
          DT_SINGLELINE or DT_VCENTER or DT_CENTER);
      end;
    finally
      ReleaseDC(Handle, hDC);
    end;
  end;
Gruß Hape


Sorry, daß ich diesen alten Thread noch mal aktiviere.
Die Lösung scheint genau das zu sein, was ich suche, aber ich hab vergeblich versucht, eine Paint procedure zu finden. Wo kann ich diesen Text oben reinschreiben.

MfG Rene
sintec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Mo 21.05.07 15:14 
user profile iconwulfskin hat folgendes geschrieben:
Alternativ kannst du dir auch eine eigene Komponente erstellen, bei der du das Zeichnen überschreibst und am Ende noch Text darauf malst.

Hier hab ich mal ein bisschen Quelltext, mit dem du Text auf die ProgressBar zeichnen kannst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
var
  hDC: THandle;
  R: TRect;
begin
  with ProgressBar1 do begin
    hDC := GetWindowDC(Handle);
    try
      if hDC <> 0 then begin
        R := ClientRect;
        SetBKMode(hDC, TRANSPARENT);
        SetTextColor(hDC, RGB(255255255));
        DrawText(hDC, 'TEST'4, R,
          DT_SINGLELINE or DT_VCENTER or DT_CENTER);
      end;
    finally
      ReleaseDC(Handle, hDC);
    end;
  end;
Gruß Hape

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.



Hallo erstmal,

der obere Code passt super zu meinem Programm, nur das Problem ist, dass ich als Text den Status in Prozent ausgebe und da mallt er alles rüber so dass man die zahlen nicht erkennen kann.

Wie kann man machen, dass er vorher den Text löscht und den neuen darauf malt?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 21.05.07 16:14 
Dann musst Du die Position deines drübergemalten Textes ggf. etwas anpassen ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
sintec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Di 22.05.07 08:37 
So sieht es aus mit dem Text in dem ProgressBar (sieh Anhang)



user profile iconBenBE hat folgendes geschrieben:
Dann musst Du die Position deines drübergemalten Textes ggf. etwas anpassen ...


Was meinst du damit und wie soll es aussehen?
Einloggen, um Attachments anzusehen!
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: Di 22.05.07 10:45 
Im Zweifelsfalle könnte man vielleicht auch eine neue Komponente schreiben, die eine Ableitung von der ProgressBar ist,
und dann den Text überschreiben.

Oder gleich ne eigene Komponente schreiben. ;)
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Di 22.05.07 10:46 
bin gerade dabei! is auch schon fast fertig!

lg el

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
sintec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Di 22.05.07 11:07 
user profile iconelundril hat folgendes geschrieben:
bin gerade dabei! is auch schon fast fertig!

lg el


könntest du dann bitte den Code hier posten?
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Di 22.05.07 14:00 
ich kann dann die komponente Posten! ;-)

lg el

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
sintec
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Di 22.05.07 14:50 
Das ist nett

danke im voraus