Autor Beitrag
Darth Sitthiander
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95



BeitragVerfasst: So 02.04.06 13:35 
Hallo

Ich hätte mal gern gewusst wie man eigentlich eine Struktur erstellt, in welcher sich ungefähr jede sekunde die Linie ändert. Ich stelle mir das so wie im Taskmanager von Windows vor. Es sollte irgendwas anzeigen können, z. B. die Downloadgeschwindigkeit oder sonst was nützliches. Mir geht es um das prinzip, welche Komponenten ich brauche und ein Quelltext wäre auch noch nützlich. Achja ein Tutorial würde es auch machen;-). Danke im Vorraus.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 02.04.06 13:39 
Als Komponente würde ich auf Anhieb ne Paintbox und einen Timer nehmen, und im OnTimer alles neu malen lassen (d.h. alles bis auf die erste Pixel-Spalte in ein Bitmap kopieren, neue Spalte hintendran malen und dann per BitBlt aufs Canvas der Paintbox rüberkopieren).

_________________
We are, we were and will not be.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 05.04.06 15:50 
meinst du ein oszilloskop ?
Darth Sitthiander Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95



BeitragVerfasst: Mi 05.04.06 15:53 
Nein das meine ich nicht. Obwohl sowas auch nützlich wäre. Für audioprogramme meine ich. Aber ich dachte da an sowas wie im Takmanager unter systemleistung. weiss nicht wie das heisst. Hoffentlich kannst du mir helfen.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 05.04.06 16:11 
Im Grunde musst du nur die Werte in einem Array speichern und dann in einem Canvas (von Formular, PaintBox, Image, ...) mit LineTo sequentiell die einzelnen Zwischenlinien zeichnen. Die müssen nur auf

Der Vorschlag von user profile iconGausi ist vermutlich langsamer und vor allem aufwändiger, wenn auch mit weniger Flackern.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 05.04.06 16:35 
Hab da mal was rumgespielt: Du brauchst ein Formular mit ner Paintbox und einem Timer (bei mir mit 25er Intervall ganz nett) (die Routinen entsprechend eintragen, bitte)
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    PaintBox1: TPaintBox;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  PaintBitmap: TBitmap;
  newvalue, oldValue: integer;

implementation

{$R *.dfm}

procedure DrawNext(SourceBmp: TBitmap; newValue: integer; oldValue: integer);
var tmpbmp: tBitmap;
  oldrec: tRect;
  newrec: tRect;
begin
  tmpbmp:= TBitmap.Create;
  tmpbmp.Width := SourceBmp.Width;
  tmpbmp.Height := SourceBmp.Height;

  // alles bis auf die erste Spalte soll beibehalten werden
  oldRec.Left := 1;
  oldRec.Right := SourceBmp.Width;
  oldRec.Top := 0;
  oldRec.Bottom := SourceBmp.Height;

  newrec.Left := 0;
  newrec.Right := SourceBmp.Width-1;
  newrec.Top := 0;
  newrec.Bottom := SourceBmp.Height;

  // das "hintere Rechteck" "um eins nach vorne schieben"
  tmpbmp.Canvas.CopyRect(newrec,SourceBmp.Canvas, oldRec);
  tmpbmp.Canvas.MoveTo(tmpbmp.Width-2,oldvalue);
  tmpbmp.Canvas.LineTo(tmpbmp.Width-1,newvalue);

  // das alte brauchen wir jetzt nciht mehr ;-)
  SourceBmp.Assign(tmpbmp);

  tmpbmp.Free;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var newvalue: integer;
begin
   // Zufallswerte nehmen
    if random(10) < 5 then
      newvalue := oldvalue + random(20)
    else
      newvalue := oldvalue - random(20);

    // sicherheitshalber: Grenzen checken ;-)
    if newvalue > PaintBitmap.Height then
      newvalue := PaintBitmap.Height DIV 2;
    if newvalue < 0 then
      newvalue := PaintBitmap.Height DIV 2;

  // neues Bild malen
  DrawNext(PaintBitmap, newvalue, oldvalue);
  BitBlt(Paintbox1.Canvas.Handle, 0,   0, PaintBitmap.Width, PaintBitmap.Height, PaintBitmap.Canvas.Handle, 0,  0, srccopy);

  // Variable umsetzen
  oldvalue := newvalue;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  randomize;
  PaintBitmap := TBitmap.Create;
  Paintbitmap.Width := Paintbox1.Width;
  Paintbitmap.Height := Paintbox1.Height;
  newvalue := Paintbox1.Height DIV 2;
  OldValue := Paintbox1.Height DIV 2;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  PaintBitmap.Free;
end;

end.

_________________
We are, we were and will not be.
Darth Sitthiander Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 95



BeitragVerfasst: Do 06.04.06 20:13 
Es funktioniert zwar mit zufälligen zahlen. Jedoch habe ich auf swissdelphipages einen code gefnden mit dem man die cpu auslastung berechnen kann, welcher sich nicht einbauen lässt. Könnt ihr mir helfen?