Autor Beitrag
Krefti
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 24.08.06 07:25 
Morgen zusammen!

Ich möchte zwei zahlen(laenge,hoehe) in je ein edit eingeben und daraus ein Rechteck zeichnen lassen, dass klappt auch.
wenn ich anschließend bei laenge die gleiche zahl wieder eingebe und bei hoehe eine andere zeichnet er nicht. erst sobald ich bei laenge eine andere zahl eingeben zeichnet er das dreieck wieder..ich hab keine ahnung woran es liegen könnte..

hier mein code:

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:
procedure TForm1.Button1Click(Sender: TObject);
begin

    If (edLaenge.Text='') or (edHoehe.Text='') then
      begin
           showmessage('Sie müssen Länge und Höhe eingeben');
           exit;
      end;
       MaleBild(Image1.Canvas);
end;
{------------------------------------------------------------------------------}
Procedure TForm1.MaleBild(Canvas1:TCanvas);
var
   laenge,hoehe: integer;
   TheRect: TRect;
begin
     laenge:=0;
     hoehe:=0;
     laenge := StrToInt(edLaenge.Text);
     hoehe  := StrToInt(edLaenge.Text);

     with Canvas1 do begin
        Pen.Color:=clBlack;
        Rectangle(Rect(50,50,laenge,hoehe));
     end;

end;
{------------------------------------------------------------------------------}
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;


Vielen dank schon mal für eure antworten!!!

gruß krefti
iKilledKenny
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 8

Win XP
D5 Prof, C# Express 2005
BeitragVerfasst: Do 24.08.06 07:53 
ausblenden Delphi-Quelltext
1:
2:
     laenge := StrToInt(edLaenge.Text);
     hoehe  := StrToInt(edHoehe.Text);


ohne deine benamsung der controls genau zu kennen, würde ich sagen, es war der copy&paste teufel, der sich hier eingeschlichen hat...

viele grüße
alex
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 24.08.06 07:58 
also ich post jetzt hier mal den komplette code, ich seh eigentlich kein copy&paste fehler..oder ich steh einfach grad mal voll aufm schlauch...

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:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,Printers;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    edLaenge: TEdit;
    Label2: TLabel;
    edHoehe: TEdit;
    Image1: TImage;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Malebild(Canvas1:TCanvas);
    procedure Button2Click(Sender: TObject);
    procedure edLaengeKeyPress(Sender: TObject; var Key: Char);
    procedure edHoeheKeyPress(Sender: TObject; var Key: Char);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{------------------------------------------------------------------------------}
procedure TForm1.Button1Click(Sender: TObject);
begin

    If (edLaenge.Text='') or (edHoehe.Text='') then
      begin
           showmessage('Sie müssen Länge und Höhe eingeben');
           exit;
      end;
       MaleBild(Image1.Canvas);
end;
{------------------------------------------------------------------------------}
Procedure TForm1.MaleBild(Canvas1:TCanvas);
var
   laenge,hoehe: integer;
   TheRect: TRect;
begin
     laenge:=0;
     hoehe:=0;
     laenge := StrToInt(edLaenge.Text);
     hoehe  := StrToInt(edLaenge.Text);

     with Canvas1 do begin
        Pen.Color:=clBlack;
        Rectangle(Rect(50,50,laenge,hoehe));
        MoveTo(50,Round((50+hoehe)/2));
        LineTo(laenge,round((50+hoehe)/2));
     end;

end;
{------------------------------------------------------------------------------}
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
{------------------------------------------------------------------------------}

procedure TForm1.edLaengeKeyPress(Sender: TObject; var Key: Char);
begin
    if not (key in ['0'..'9',  #8]) then begin
       showmessage('Sie dürfen nur Zahlen eingeben!');
         key := #0;
         exit;
     end;
end;
{------------------------------------------------------------------------------}

procedure TForm1.edHoeheKeyPress(Sender: TObject; var Key: Char);
begin
    if not (key in ['0'..'9',  #8]) then begin
       showmessage('Sie dürfen nur Zahlen eingeben!');
         key := #0;
         exit;
     end;
end;
{------------------------------------------------------------------------------}

end.
iKilledKenny
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 8

Win XP
D5 Prof, C# Express 2005
BeitragVerfasst: Do 24.08.06 08:09 
du weist der hoehe den inhalt von edLaenge zu...
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 24.08.06 08:14 
:oops: ups...in meiner morgenlichen aufwachphase hab ich des doch glatt übersehe..also nochmal herzlichen dank!!!