Autor Beitrag
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Mo 26.05.08 18:42 
Hallihallo, Ich bins nochmal mit einer wahrscheinlich idiotischen Frage... Ich habe hier eine Prozedur (angefangen) zu schreiben. als ich die Prozedur 1:1 mit einer PaintBox habe durchlaufen lassen, ist nichts passiert (WIRKLICH GAAR NIX). Aber mit dem hässlichen Image(hier sogar hässlich benannt) klappts plötzlich...

ausblenden 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:
procedure TForm2.DrawCoord;
var
  i     : integer;
begin
    With Image1.Canvas do
    begin
      Pen.Color:= $66666666; // color settings

      MoveTo(Image1.width div 2 , 0); //MoveTo Center/Bottom of Paintbox
      LineTo(Image1.Width div 2 , Image1.Height); // Y-Axis

      MoveTo(0 , Image1.Height div 2); //MoveTo Center/Left of Paintbox
      LineTo(Image1.Width, Image1.Height div 2); // X-Axis

      // separation
      while i < Image1.width do
        begin
          moveTo(Image1.Width div 2 + 2 , i);
          LineTo(Image1.Width div 2 - 2 , i);
          inc(i,2);


        end;
    end;
  Image1.Refresh;
end;
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mo 26.05.08 19:19 
Ich seh in deinem Post irgendwie kein Fragezeichen, worauf man antworten könnte.. :P

Wie hattest du das denn vorher mit der PaintBox?

Eine Paintbox wird normalerweise einmal gezeichnet. Wenn du da etwas drüberschiebst, z.B. ein anderes Fenster oder so, wird sie nicht standardmäßig neu gezeichnet (nur ein Event ausgelöst, worauf man reagieren kann). Ein Image jedoch "merkt" sich den Inhalt, und zeichnet den bei Bedarf selber neu - vielleicht ist das dein Problem?
FinnO Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Mo 26.05.08 19:26 
naja ich hab halt das image fr das Paintbox eingesetzt... hab mich einfach gewundert warum nix passiert... machs jetzt aber mit Image;
ub60
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 765
Erhaltene Danke: 130



BeitragVerfasst: Mo 26.05.08 20:34 
Das Problem wird daran liegen, dass Du die Variable i vor der Schleife nicht initialisiert hast (i:=0;).
So erhält i einen zufälligen Wert und der war bei einem der Fälle offensichtlich größer als die Abbruchbedingung.

ub60
FinnO Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Di 27.05.08 18:18 
i wird in einer anderen Procedure initialisiert... ist globl (seit neustem) :D
turboPASCAL
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 193
Erhaltene Danke: 1

Win XP / Vischda
D6 PE / D2005 PE
BeitragVerfasst: Mi 28.05.08 02:10 
Wan rufst du denn die Procedure DrawCoord auf, im OnPaint der PaintBox ?
Das sollte dann funktionieren. Denke daran bei DrawCoord auf die
Verwendung Refresh für sie PaintBox zu verzichten sonst
gibt es eine Schleife.

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:
// ...
type
  TForm1 = class(TForm)
    PaintBox1: TPaintBox;
    procedure PaintBox1Paint(Sender: TObject);
  private
    { Private-Deklarationen }
    procedure DrawCoord;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DrawCoord;
var
  i     : integer;
begin
    With PaintBox1.Canvas do
    begin
      Pen.Color:= $00666666; // color settings
      MoveTo(PaintBox1.width div 2 , 0); //MoveTo Center/Bottom of Paintbox
      LineTo(PaintBox1.Width div 2 , PaintBox1.Height); // Y-Axis
      MoveTo(0 , PaintBox1.Height div 2); //MoveTo Center/Left of Paintbox
      LineTo(PaintBox1.Width, PaintBox1.Height div 2); // X-Axis
      // separation
      i := 0;
      while i < PaintBox1.width do
        begin
          moveTo(PaintBox1.Width div 2 + 2 , i);
          LineTo(PaintBox1.Width div 2 - 2 , i);
          inc(i,2);
        end;
    end;
end;

procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
  DrawCoord;
end;

end.

_________________
Nein, ich bin nicht der turboPASCAL aus der DP, ich seh nur so aus... :P