Autor Beitrag
rizor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 01.10.06 23:24 
Hi,

mein Programm zeichnet nicht, wie ich will.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
  Form1.Canvas.Brush.Color:=clWhite;
  Form1.Canvas.Rectangle(0,0,form1.Width,form1.Height);
  Form1.canvas.pen.color:=clblack;
  xur:=form1.width div 2;
  yur:=form1.height div 2;
  xmax:=form1.width;
  ymax:=form1.height;
  MoveTo(10,yur);
  LineTo(xmax-10,yur);
  MoveTo(xur,10);
  LineTo(xur,ymax-10);


Woran liegt das?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 01.10.06 23:28 
-In welcher Methode befindet sich dieser Code?
-Was soll das Programm zeichnen?
-Was zeichnet es?

_________________
Markus Kinzler.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 01.10.06 23:36 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Form1.Canvas.Brush.Color:=clWhite;
  Form1.Canvas.Rectangle(0,0,form1.Width,form1.Height);
  Form1.canvas.pen.color:=clblack;
  xur:=form1.width div 2;
  yur:=form1.height div 2;
  xmax:=form1.width;
  ymax:=form1.height;
  Canvas.MoveTo(10,yur);
  Canvas.LineTo(xmax-10,yur);
  Canvas.MoveTo(xur,10);
  Canvas.LineTo(xur,ymax-10);
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Mo 02.10.06 12:02 
Das Programm soll zwei geraden zeihcnen, dass sich in der mitte schneidet.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 02.10.06 12:16 
noch einmal, wo steht denn dein Code?

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
aim65
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 312

Win 9x, Win XP
Delphi 3pro, 7PE
BeitragVerfasst: Mo 02.10.06 12:36 
Du mußt das in einem Event aufrufen (z.B., ButtonClick oder wie hier in Form.Paint). Zweitens kriegst du ne Fehlermeldung bei "MoveTo / LineTo", da du auch dort den Canvas definieren mußt (siehe Blackheart66).
Probier das mal:
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:
procedure TForm1.FormActivate(Sender: TObject);
begin
  Form1.Paint;
end;

procedure TForm1.FormPaint(Sender: TObject);
var xur,yur,xmax,ymax: Integer;
begin
  xur:=form1.width div 2;
  yur:=form1.height div 2;
  xmax:=form1.width;
  ymax:=form1.height;
  with Form1.Canvas do  //<--- spart 'ne Menge Schreiberei
  begin
    Brush.Color:=clWhite;
    Rectangle(0,0,form1.Width,form1.Height);
    Pen.color:=clblack;
    MoveTo(10,yur);
    LineTo(xmax-10,yur);
    MoveTo(xur,10);
    LineTo(xur,ymax-10);
  end;
end;
kotzekocher
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Mo 02.10.06 13:23 
Kürzer:
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:
procedure TForm1.FormActivate(Sender: TObject);   
begin   
  Paint;   
end;   

procedure TForm1.FormPaint(Sender: TObject);   
var xur,yur,xmax,ymax: Integer;   
begin   
  xur:=width div 2;   
  yur:=height div 2;   
  xmax:=width;   
  ymax:=height;   
  with Canvas do  //<--- spart 'ne Menge Schreiberei   
  begin   
    Brush.Color:=clWhite;   
    Rectangle(0,0, Width, Height);   
    Pen.color:=clblack;   
    MoveTo(10,yur);   
    LineTo(xmax-10,yur);   
    MoveTo(xur,10);   
    LineTo(xur,ymax-10);   
  end;   
end;