Autor Beitrag
Dude566
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Mo 10.11.08 20:22 
Also das Projekt ist ein Paint Programm bei dem Koordinaten eingegeben werden können, oder Zufällige erzeugt werden. Aus diesen werden verschiedene Figuren gezeichnet.

1. Die Ausgabe der gespeicherten Koordinaten in den Arrays werden nicht in der ListBox1 ausgegeben.

2. Sollen wir den Kreis mit Radiusdaten angeben können, ich habe aber nur über die Ellipse Funktion einen Kreis.

3. Sollen wir die Fläche der Figuren berechnen, das ginge doch einfach wenn ich die eingegebenen Koordinaten in die Formeln einsetze oder? Ich weis nicht wie ich es anstellen soll und hätte gerne Vorschläge.

Hier mal der Text:

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:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    PaintBox1: TPaintBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Edit3: TEdit;
    Edit4: TEdit;
    Label9: TLabel;
    Label10: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    RadioButton6: TRadioButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Edit5: TEdit;
    Edit6: TEdit;
    Label11: TLabel;
    Label12: TLabel;
    Button9: TButton;
    Button10: TButton;
    ListBox1: TListBox;
    Button11: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Edit1Enter(Sender: TObject);
    procedure Edit2Enter(Sender: TObject);
    procedure Button11Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

  TLinie = Record            // Datentyp für Linien
           x1,y1:integer;
           x2,y2:integer;
           end;

  TDreieck = Record            // Datentyp für das Dreieck
             x1,y1:integer;
             x2,y2:integer;
             x3,y3:integer;
             end;

  TPunkt = Record              // Datentyp für Punkte
           x1,y1:integer;
           end;

var
  Form1: TForm1;
  punkt : array [1..100] of TPunkt;      // Array der Punkte
  linie : array [1..100] of TLinie;      // Array der Linien
  rechteck : array [1..100] of TLinie;    // Array der Rechtecke
  kreis : array [1..100] of TLinie;      // Array der Kreise
  dreieck : array [1..100] of TDreieck;  // Array der Dreiecke
  counter1, counter2, counter3, counter4, counter5 : integer;
  i : integer;

implementation

uses Unit2;

{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);   // Linie zeichnen
begin
  if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
  if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
  if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
  if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
  if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
  if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
  counter1 := counter1+1;
  linie[counter1].x1 := StrToInt(Edit1.Text);
  linie[counter1].y1 := StrToInt(Edit2.Text);
  linie[counter1].x2 := StrToInt(Edit3.Text);
  linie[counter1].y2 := StrToInt(Edit4.Text);
  PaintBox1.Canvas.MoveTo(linie[counter1].x1, linie[counter1].y1);
  PaintBox1.Canvas.LineTo(linie[counter1].x2, linie[counter1].y2);

end;

procedure TForm1.Button2Click(Sender: TObject);     // Rechteck zeichnen
begin
   if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
   if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
   if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
   if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
   if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
   if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
   counter2 := counter2+1;
   rechteck[counter2].x1 := StrToInt(Edit1.Text);
   rechteck[counter2].y1 := StrToInt(Edit2.Text);
   rechteck[counter2].x2 := StrToInt(Edit3.Text);
   rechteck[counter2].y2 := StrToInt(Edit4.Text);
   PaintBox1.Canvas.Rectangle(rechteck[counter2].x1,
                              rechteck[counter2].y1,
                              rechteck[counter2].x2,
                              rechteck[counter2].y2);
end;

procedure TForm1.Button3Click(Sender: TObject);   // Kreis zeichnen
begin
    if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
    if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
    if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
    if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
    if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
    if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
    counter3 := counter3+1;
    kreis[counter3].x1 := StrToInt(Edit1.Text);
    kreis[counter3].y1 := StrToInt(Edit2.Text);
    kreis[counter3].x2 := StrToInt(Edit3.Text);
    kreis[counter3].y2 := StrToInt(Edit4.Text);
    PaintBox1.Canvas.Ellipse (kreis[counter3].x1,
                              kreis[counter3].y1,
                              kreis[counter3].x2,
                              kreis[counter3].y2);
end;

procedure TForm1.Button4Click(Sender: TObject);   // PaintBox leeren
begin
   PaintBox1.Refresh;
end;

procedure TForm1.FormCreate(Sender: TObject);      //  Startwerte für Counter
begin
 counter1 := 0;
 counter2 := 0;
 counter3 := 0;
 counter4 := 0;
 counter5 := 0;
end;

procedure TForm1.Button5Click(Sender: TObject);    // Anwendung beenden
begin
  Form1.Close;
end;

procedure TForm1.Button6Click(Sender: TObject);  // Edit mit Zufallszahlen füllen
begin
  randomize;
  Edit1.Text := IntToStr(random(401)+1);
  Edit2.Text := IntToStr(random(401)+1);
  Edit3.Text := IntToStr(random(401)+1);
  Edit4.Text := IntToStr(random(401)+1);
  Edit5.Text := IntToStr(random(401)+1);
  Edit6.Text := IntToStr(random(401)+1);
end;

procedure TForm1.Button7Click(Sender: TObject);       // Gespeicherte Zeichnungen
begin
    PaintBox1.Canvas.MoveTo(linie[counter1].x1, linie[counter1].y1);
    PaintBox1.Canvas.LineTo(linie[counter1].x2, linie[counter1].y2);

    PaintBox1.Canvas.Rectangle(rechteck[counter2].x1,
                               rechteck[counter2].y1,
                               rechteck[counter2].x2,
                               rechteck[counter2].y2);

    PaintBox1.Canvas.Ellipse (kreis[counter3].x1,
                              kreis[counter3].y1,
                              kreis[counter3].x2,
                              kreis[counter3].y2);

    PaintBox1.Canvas.MoveTo(dreieck[counter4].x1,
                            dreieck[counter4].y1);
    PaintBox1.Canvas.LineTo(dreieck[counter4].x2,
                            dreieck[counter4].y2);
    PaintBox1.Canvas.LineTo(dreieck[counter4].x3,
                            dreieck[counter4].y3);
    PaintBox1.Canvas.LineTo(dreieck[counter4].x1,
                            dreieck[counter4].y1);
end;

procedure TForm1.Button8Click(Sender: TObject);   // Hilfefenster aufrufen
begin
  Form2.Show;
end;

procedure TForm1.Button9Click(Sender: TObject);  // Dreieck zeichnen
begin
  if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
  if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
  if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
  if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
  if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
  if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
  counter4 := counter4+1;
  dreieck[counter4].x1 := StrToInt(Edit1.Text);
  dreieck[counter4].y1 := StrToInt(Edit2.Text);
  dreieck[counter4].x2 := StrToInt(Edit3.Text);
  dreieck[counter4].y2 := StrToInt(Edit4.Text);
  dreieck[counter4].x3 := StrToInt(Edit5.Text);
  dreieck[counter4].y3 := StrToInt(Edit6.Text);
  PaintBox1.Canvas.MoveTo(dreieck[counter4].x1,
                          dreieck[counter4].y1);
  PaintBox1.Canvas.LineTo(dreieck[counter4].x2,
                          dreieck[counter4].y2);
  PaintBox1.Canvas.LineTo(dreieck[counter4].x3,
                          dreieck[counter4].y3);
  PaintBox1.Canvas.LineTo(dreieck[counter4].x1,
                          dreieck[counter4].y1);
end;

procedure TForm1.Button10Click(Sender: TObject);  // Punkt zeichnen
begin
   if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
   if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
   if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
   if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
   if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
   if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
   counter5 := counter5+1;
   punkt[counter5].x1 := StrToInt(Edit1.Text);
   punkt[counter5].y1 := StrToInt(Edit2.Text);
   PaintBox1.Canvas.Pixels[punkt[counter5].x1, punkt[counter5].y1];
end;

procedure TForm1.Edit1Enter(Sender: TObject);
begin
  Edit1.Clear;
end;


procedure TForm1.Edit2Enter(Sender: TObject);
begin
  Edit2.Clear;
end;

procedure TForm1.Button11Click(Sender: TObject);  // Koordinaten in ListBox1
begin
   for i := 1 to counter1 do ListBox1.Items.Add(IntToStr(linie));
   for i := 1 to counter2 do ListBox1.Items.Add(IntToStr(rechteck));
   for i := 1 to counter3 do ListBox1.Items.Add(IntToStr(kreis));
   for i := 1 to counter4 do ListBox1.Items.Add(IntToStr(dreieck));
end;

end.


Danke schonmal für eure Hilfe!
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 10.11.08 20:41 
Ah OK.

1. Das müsste ich mir mal in Ruhe ansehen. Sieht jedoch nicht sehr sauber aus. Ich denke aber: Irgendeine Bedingung wird wahrscheinlich falsch formuliert sein.
2. Canvas.Ellipse(MitteX - Radius, MitteY - Radius, MitteX + Radius, MitteY + Radius)
3. ja, das würde ich auch so machen. Ne andere Möglichkeit würde mir jetzt auch nicht einfallen.

EDIT zu 1.: Am besten wäre es, du lädst das Projekt hoch oder sendest zumindest noch die DFM-Datei. :D
Dude566 Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Mo 10.11.08 20:47 
Was meinst du mit "unsauber"? Ich werde es nachher mal hochladen.


Zuletzt bearbeitet von Dude566 am Mo 01.12.08 22:06, insgesamt 1-mal bearbeitet
Dude566 Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Mo 17.11.08 17:44 
1. Also habe jetzt soweit fast alles, es werden bei der Funktion das alles wieder gezeichnet werden soll, jedoch nur immer ein paar Linien ausgegeben.

2. Die Ausgabe aller eingespeicherten Koordinaten in eine Listbox klappt auch nicht dort sagt er mir " Es gibt keine überladene Version von IntToStr....".

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:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    PaintBox1: TPaintBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Edit3: TEdit;
    Edit4: TEdit;
    Label9: TLabel;
    Label10: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    RadioButton6: TRadioButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Edit5: TEdit;
    Edit6: TEdit;
    Label11: TLabel;
    Label12: TLabel;
    Button9: TButton;
    Button10: TButton;
    ListBox1: TListBox;
    Button11: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Edit1Enter(Sender: TObject);
    procedure Edit2Enter(Sender: TObject);
    procedure Button11Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

  TLinie = Record            // Datentyp für Linien
           x1,y1:integer;
           x2,y2:integer;
           end;

  TDreieck = Record            // Datentyp für das Dreieck
             x1,y1:integer;
             x2,y2:integer;
             x3,y3:integer;
             end;

  TPunkt = Record              // Datentyp für Punkte
           x1,y1:integer;
           end;

var
  Form1: TForm1;
  punkt : array [1..100] of TPunkt;      // Array der Punkte
  linie : array [1..100] of TLinie;      // Array der Linien
  rechteck : array [1..100] of TLinie;    // Array der Rechtecke
  kreis : array [1..100] of TLinie;      // Array der Kreise
  dreieck : array [1..100] of TDreieck;  // Array der Dreiecke
  counter : integer;
  i : integer;

implementation

uses Unit2;

{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);   // Linie zeichnen
begin
  if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
  if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
  if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
  if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
  if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
  if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
  counter := counter+1;
  linie[counter].x1 := StrToInt(Edit1.Text);
  linie[counter].y1 := StrToInt(Edit2.Text);
  linie[counter].x2 := StrToInt(Edit3.Text);
  linie[counter].y2 := StrToInt(Edit4.Text);
  PaintBox1.Canvas.MoveTo(linie[counter].x1, linie[counter].y1);
  PaintBox1.Canvas.LineTo(linie[counter].x2, linie[counter].y2);

end;

procedure TForm1.Button2Click(Sender: TObject);     // Rechteck zeichnen
begin
   if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
   if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
   if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
   if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
   if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
   if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
   counter := counter+1;
   rechteck[counter].x1 := StrToInt(Edit1.Text);
   rechteck[counter].y1 := StrToInt(Edit2.Text);
   rechteck[counter].x2 := StrToInt(Edit3.Text);
   rechteck[counter].y2 := StrToInt(Edit4.Text);
   PaintBox1.Canvas.Rectangle(rechteck[counter].x1,
                              rechteck[counter].y1,
                              rechteck[counter].x2,
                              rechteck[counter].y2);
end;

procedure TForm1.Button3Click(Sender: TObject);   // Kreis zeichnen
begin
    if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
    if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
    if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
    if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
    if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
    if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
    counter := counter+1;
    kreis[counter].x1 := StrToInt(Edit1.Text);
    kreis[counter].y1 := StrToInt(Edit2.Text);
    kreis[counter].x2 := StrToInt(Edit3.Text);
    kreis[counter].y2 := StrToInt(Edit4.Text);
    PaintBox1.Canvas.Ellipse (kreis[counter].x1,
                              kreis[counter].y1,
                              kreis[counter].x2,
                              kreis[counter].y2);
end;

procedure TForm1.Button4Click(Sender: TObject);   // PaintBox leeren
begin
   PaintBox1.Refresh;
end;

procedure TForm1.FormCreate(Sender: TObject);      //  Startwert für Counter
begin
 counter := 0;
end;

procedure TForm1.Button5Click(Sender: TObject);    // Anwendung beenden
begin
  Form1.Close;
end;

procedure TForm1.Button6Click(Sender: TObject);  // Edit mit Zufallszahlen füllen
begin
  randomize;
  Edit1.Text := IntToStr(random(401)+1);
  Edit2.Text := IntToStr(random(401)+1);
  Edit3.Text := IntToStr(random(401)+1);
  Edit4.Text := IntToStr(random(401)+1);
  Edit5.Text := IntToStr(random(401)+1);
  Edit6.Text := IntToStr(random(401)+1);
end;

procedure TForm1.Button7Click(Sender: TObject);       // Gespeicherte Zeichnungen
begin
    PaintBox1.Canvas.MoveTo(linie[counter].x1, linie[counter].y1);
    PaintBox1.Canvas.LineTo(linie[counter].x2, linie[counter].y2);

    PaintBox1.Canvas.Rectangle(rechteck[counter].x1,
                               rechteck[counter].y1,
                               rechteck[counter].x2,
                               rechteck[counter].y2);

    PaintBox1.Canvas.Ellipse (kreis[counter].x1,
                              kreis[counter].y1,
                              kreis[counter].x2,
                              kreis[counter].y2);

    PaintBox1.Canvas.MoveTo(dreieck[counter].x1,
                            dreieck[counter].y1);
    PaintBox1.Canvas.LineTo(dreieck[counter].x2,
                            dreieck[counter].y2);
    PaintBox1.Canvas.LineTo(dreieck[counter].x3,
                            dreieck[counter].y3);
    PaintBox1.Canvas.LineTo(dreieck[counter].x1,
                            dreieck[counter].y1);
end;

procedure TForm1.Button8Click(Sender: TObject);   // Hilfefenster aufrufen
begin
  Form2.Show;
end;

procedure TForm1.Button9Click(Sender: TObject);  // Dreieck zeichnen
begin
  if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
  if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
  if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
  if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
  if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
  if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
  counter := counter+1;
  dreieck[counter].x1 := StrToInt(Edit1.Text);
  dreieck[counter].y1 := StrToInt(Edit2.Text);
  dreieck[counter].x2 := StrToInt(Edit3.Text);
  dreieck[counter].y2 := StrToInt(Edit4.Text);
  dreieck[counter].x3 := StrToInt(Edit5.Text);
  dreieck[counter].y3 := StrToInt(Edit6.Text);
  PaintBox1.Canvas.MoveTo(dreieck[counter].x1,
                          dreieck[counter].y1);
  PaintBox1.Canvas.LineTo(dreieck[counter].x2,
                          dreieck[counter].y2);
  PaintBox1.Canvas.LineTo(dreieck[counter].x3,
                          dreieck[counter].y3);
  PaintBox1.Canvas.LineTo(dreieck[counter].x1,
                          dreieck[counter].y1);
end;

procedure TForm1.Button10Click(Sender: TObject);  // Punkt zeichnen
begin
   if RadioButton1.Checked then PaintBox1.Canvas.Pen.Color := ClBlack;
   if RadioButton2.Checked then PaintBox1.Canvas.Pen.Color := ClRed;
   if RadioButton3.Checked then PaintBox1.Canvas.Pen.Color := ClGreen;
   if RadioButton4.Checked then PaintBox1.Canvas.Pen.Color := ClBlue;
   if RadioButton5.Checked then PaintBox1.Canvas.Pen.Color := ClYellow;
   if RadioButton6.Checked then PaintBox1.Canvas.Pen.Color := ClFuchsia;
   counter := counter+1;
   punkt[counter].x1 := StrToInt(Edit1.Text);
   punkt[counter].y1 := StrToInt(Edit2.Text);
   PaintBox1.Canvas.Pixels[punkt[counter].x1, punkt[counter].y1];
end;

procedure TForm1.Edit1Enter(Sender: TObject);
begin
  Edit1.Clear;
end;


procedure TForm1.Edit2Enter(Sender: TObject);
begin
  Edit2.Clear;
end;

procedure TForm1.Button11Click(Sender: TObject);    // Ausgabe von Koordinaten in ListBox
begin
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(linie));
end;

end.
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Mo 17.11.08 18:14 
Naja, das funktioniert nicht, weil Linie kein Integer ist. So eine Fehlermeldung bedeutet immer, dass deine Argumente nicht stimmen, in diesem Fall also Linie. Integer wären aber zum Beispiel Linie.x1 oder sowas. :wink:
Dude566 Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Mo 17.11.08 18:27 
Delphi sagt mir : "Undefinierter Bezeichner "LinieToStr" ".

Und was ist mit dem 1. Problem?
Jerk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Di 18.11.08 12:47 
1. Ich finde garkeine Funktion in deinem Queltext?!
2.Line ist ja nen Array vom Typ record und kein Integer. inttostr(Linie[1].x) würde gehen.
Dude566 Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Di 18.11.08 16:51 
Ja und was muss ich ändern oder komplett anders machen?
Jerk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Di 18.11.08 20:35 
user profile iconJerk hat folgendes geschrieben Zum zitierten Posting springen:
inttostr(Linie[1].x) würde gehen.

Sagmal ziegst du eigentlich nie Eigenintitiative?
Dude566 Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Di 18.11.08 21:20 
Doch, ich verstehe nur nicht warum das andere nicht auch gehen kann.
Und bist du immer so negativ und unfreundlich wenn jemand nicht direkt das Problem selber erkennt?
Jerk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Mi 19.11.08 08:10 
Das du was nich verstehst ist nich das Problem, sondern das du immer gleich nach ner Lösung fragst statt selbst eine mit den Antworten zu suchen. Ersetze doch einfachmal dein inttostr(Linie) im Quelltext (Zeile 266) mit dem was ich geschrieben habe.

Wenn du jetzt noch davon ausgehst das das Array sicherlich nicht nur das Feld 1 hat musst du noch die 1 durch deine Zählervariable ersetzen.
Dude566 Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Mi 19.11.08 20:29 
Ich hab nach einer Lösung gesucht, doch keine gefunden, und da dachte ich mir fragste mal die Leute aus dem Forum. So danke ich habs jetzt hingekriegt, auch wenn ich euch mit meinen Fragen genervt hab! :D
Dude566 Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Do 20.11.08 17:21 
Mmmh jetzt spuckt er nur nullen in der Listbox aus, aber immerhin etwas. Ich glaube es könnte am Startwert liegen. Aber das Problem das er alle eingespeicherten nochmal Zeichnen soll macht er immer noch nicht. Er zeichnet nur die letzte Zeichnung (Figur), jemand ne idee woran das liegen könnte?

PS: Ist dringend.
Dude566 Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Di 25.11.08 18:19 
Also wir schreiben morgen eine Arbeit in Programmieren und da hab ich eben schnell zur Übung noch mal ein Paint Programm geschrieben. Da ist mir auf-(ein)gefallen das die Ausgabe der Koordinaten in die ListBox immer noch nicht ganz funktioniert.
Es werden immer nur die Koordinaten der letzen Zeichnung ausgegeben un der Rest sind Nullen.

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:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    PaintBox1: TPaintBox;
    Edit5: TEdit;
    Edit6: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    ListBox1: TListBox;
    Button7: TButton;
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;
  TLinie = record
           x1,x2,y1,y2 : integer;
           end;
  TDreieck = record
             x1,x2,x3,y1,y2,y3 : integer;
             end;
var
  Form1: TForm1;
  counter : integer;
  linie : array [1..100] of Tlinie;
  rechteck : array [1..100] of Tlinie;
  kreis : array [1..100] of Tlinie;
  dreieck : array [1..100] of TDreieck;
  i : integer;

implementation

{$R *.DFM}

procedure TForm1.Button5Click(Sender: TObject);     // Paintbox Refresh
begin
   PaintBox1.Refresh;
end;

procedure TForm1.Button6Click(Sender: TObject);    // Zufallszahlen
begin
   randomize;
   Edit1.Text := IntToStr(random(100)+1);
   Edit2.Text := IntToStr(random(100)+1);
   Edit3.Text := IntToStr(random(100)+1);
   Edit4.Text := IntToStr(random(100)+1);
   Edit5.Text := IntToStr(random(100)+1);
   Edit6.Text := IntToStr(random(100)+1);
end;

procedure TForm1.Button1Click(Sender: TObject);   // Linie
begin
  if counter < 100 then begin
  counter := counter+1;
  linie[counter].x1 := StrToInt(Edit1.Text);
  linie[counter].y1 := StrToInt(Edit2.Text);
  linie[counter].x2 := StrToInt(Edit3.Text);
  linie[counter].y2 := StrToInt(Edit4.Text);
  PaintBox1.Canvas.MoveTo(linie[counter].x1,
                          linie[counter].y1);
  PaintBox1.Canvas.LineTo(linie[counter].x2,
                          linie[counter].y2);
                     end
  else ShowMessage ('Array ist voll!');

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
    if counter < 100 then begin
    counter := counter+1;
    rechteck[counter].x1 := StrToInt(Edit1.Text);
    rechteck[counter].y1 := StrToInt(Edit2.Text);
    rechteck[counter].x2 := StrToInt(Edit3.Text);
    rechteck[counter].y2 := StrToInt(Edit4.Text);
    PaintBox1.Canvas.Rectangle(rechteck[counter].x1, rechteck[counter].y1,
                               rechteck[counter].x2, rechteck[counter].y2);
                          end
    else ShowMessage ('Array ist voll!');
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
   if counter < 100 then begin
   counter := counter+1;
   dreieck[counter].x1 := StrToInt(Edit1.Text);
   dreieck[counter].y1 := StrToInt(Edit2.Text);
   dreieck[counter].x2 := StrToInt(Edit3.Text);
   dreieck[counter].y2 := StrToInt(Edit4.Text);
   dreieck[counter].x3 := StrToInt(Edit5.Text);
   dreieck[counter].y3 := StrToInt(Edit6.Text);
   PaintBox1.Canvas.MoveTo(dreieck[counter].x1,
                           dreieck[counter].y1);
   PaintBox1.Canvas.LineTo(dreieck[counter].x2,
                           dreieck[counter].y2);
   PaintBox1.Canvas.LineTo(dreieck[counter].x3,
                           dreieck[counter].y3);
   PaintBox1.Canvas.LineTo(dreieck[counter].x1,
                           dreieck[counter].y1);
                           end
   else ShowMessage ('Array ist voll!');

end;

procedure TForm1.Button2Click(Sender: TObject);
var
r : array [1..100] of integer;

begin
   if counter < 100 then begin
   counter := counter+1;
   kreis[counter].x1 := StrToInt(Edit7.Text);
   kreis[counter].y1 := StrToInt(Edit8.Text);
   r[counter] := StrToInt(Edit9.Text);
   PaintBox1.Canvas.Ellipse(kreis[counter].x1 - r[counter],
                            kreis[counter].y1 - r[counter],
                            kreis[counter].x1 + r[counter],
                            kreis[counter].y1 + r[counter]);
                            end
   else ShowMessage ('Array ist voll!');
end;

procedure TForm1.Button7Click(Sender: TObject);    // Ausgabe in ListBox
var
r : array [1..100] of integer;
begin
   ListBox1.Items.Add('Linien');
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(linie[counter].x1));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(linie[counter].y1));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(linie[counter].x2));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(linie[counter].y2));

   ListBox1.Items.Add('Rechtecke');
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(rechteck[counter].x1));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(rechteck[counter].y1));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(rechteck[counter].x2));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(rechteck[counter].y2));

   ListBox1.Items.Add('Dreiecke');
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(dreieck[counter].x1));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(dreieck[counter].y1));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(dreieck[counter].x2));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(dreieck[counter].y2));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(dreieck[counter].x3));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(dreieck[counter].y3));

   ListBox1.Items.Add('Kreise');
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(kreis[counter].x1));
   for i := 1 to counter do ListBox1.Items.Add(IntToStr(r[counter]));
end;

end.


Schonmal Danke für eure schnelle Hilfe! ;)
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Di 25.11.08 18:35 
Du benutzt als Schleifenvariable i aber auf die Elemente deines Arrays greifst du mit counter zu. In counter steht logischerweise immer die gleiche Zahl, da ja i die Schleifenvariable ist und hochgezählt wird.

Kleiner Hinweis am Rande: Die Prozedur Randomize sollte pro Programm nur einmal aufgerufen werden - in deinem Fall macht's keinen Unterschied aber es gibt Anwendungsbeispiele, bei denen der wiederholte Aufruf Probleme bereitet, darum empfehle ich, es dir gleich anzugewöhnen, Randomize nur z.B. im Form1Create aufzurufen(simpel und meist genug), oder in der *.dpr vor dem Application.Initialize (optimal).

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.