Autor Beitrag
TheProgrammer
Hält's aus hier
Beiträge: 13

WindowsXP
Borland Delphi 7, Microsoft Visual Studio, Blitz3D, BlitzPlus
BeitragVerfasst: Di 11.09.07 15:14 
Hi :)

ich denke mal, der Titel sagt alles. ^^ Ich möchte meine Komponenten (z.B. Buttons) zur Laufzeit des Programmes erstellen lassen.
Ich habe mehrere Komponenten, die in ein array gespeichert werden sollen.

Ich hoffe, ihr könnt mir da weiterhelfen. :) Danke schonmal im voraus.

Mfg
TheProgrammer

_________________
AMD Athlon XP 2100+ (1,73 GHz) | 768 MB RAM | NvIDIA GeForce 5200 FX | 160 GB Festplatte | WinXP Professional Edition


Zuletzt bearbeitet von TheProgrammer am Di 11.09.07 20:06, insgesamt 1-mal bearbeitet
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Di 11.09.07 15:22 
Wo ist denn das spezifische Problem?

_________________
Bravery calls my name in the sound of the wind in the night...
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 11.09.07 15:22 
ausblenden Delphi-Quelltext
1:
2:
3:
Buttons[i] := TButton.Create (<Owner>);
Buttons[i].parent := <parent>;
Buttons[i].Left ...

_________________
Markus Kinzler.
TheProgrammer Threadstarter
Hält's aus hier
Beiträge: 13

WindowsXP
Borland Delphi 7, Microsoft Visual Studio, Blitz3D, BlitzPlus
BeitragVerfasst: Di 11.09.07 15:36 
Vielen Dank, hat mir sehr geholfen ^^

_________________
AMD Athlon XP 2100+ (1,73 GHz) | 768 MB RAM | NvIDIA GeForce 5200 FX | 160 GB Festplatte | WinXP Professional Edition
TheProgrammer Threadstarter
Hält's aus hier
Beiträge: 13

WindowsXP
Borland Delphi 7, Microsoft Visual Studio, Blitz3D, BlitzPlus
BeitragVerfasst: Di 11.09.07 18:24 
Hmm... ich hab das jetzt mal getestet, jedoch liefert mir der Debugger einen Fehler. :(

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.FormCreate(Sender: TObject);
var button:TButton;
begin
  button := TButton.create();
  button.left:=1;
  button.top:=1;
  button.width:=17;
  button.height:=17;
end;


und der Fehler:

ausblenden Delphi-Quelltext
1:
[Fehler] Unit1.pas(26): Undefinierter Bezeichner: 'TButton'					


Mfg

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt

_________________
AMD Athlon XP 2100+ (1,73 GHz) | 768 MB RAM | NvIDIA GeForce 5200 FX | 160 GB Festplatte | WinXP Professional Edition
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Di 11.09.07 18:35 
Unit StdCtrls eingebunden?

PS: Der Fehler kommt vom Compiler!

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
ub60
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 766
Erhaltene Danke: 131



BeitragVerfasst: Di 11.09.07 18:38 
ausblenden Delphi-Quelltext
1:
uses StdCtrls;					


Jetzt sollte es funktionieren.

ub60

-----------
edit: jakob war schneller ;-)
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 11.09.07 18:41 
Wenn ich jetzt das hier eingebe:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Button1Click(Sender: TObject);
var i, tp: Integer;
begin
  tp := 64;
  for i := 0 to 9 do
  begin
    Form1.labels[i] := TLabel.Create(Form1);
    Form1.labels[i].Parent := Form1.ActiveControl;
    Form1.labels[i].Left := 10;
    Form1.labels[i].Top := tp;
    Form1.labels[i].Caption := IntToStr(i+1);
    tp := tp + 16;
  end;
  Form1.Repaint;
end;

Dann wird nichts angezeigt....
TheProgrammer Threadstarter
Hält's aus hier
Beiträge: 13

WindowsXP
Borland Delphi 7, Microsoft Visual Studio, Blitz3D, BlitzPlus
BeitragVerfasst: Di 11.09.07 18:43 
Ah, vielen vielen Dank. :) Jetzt funktioniert es. ^^

_________________
AMD Athlon XP 2100+ (1,73 GHz) | 768 MB RAM | NvIDIA GeForce 5200 FX | 160 GB Festplatte | WinXP Professional Edition
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 11.09.07 18:45 
Und wieso bei mir nicht??????
Das regt mich auf...
Seht ihr das:
user defined image
Merke: Böses Gesicht!
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Di 11.09.07 18:56 
Haste mal gedebuggt und geguckt, ob der Code überhaupt aufgerufen wird, usw. ?

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Di 11.09.07 18:58 
Jup... wird er...
TheProgrammer Threadstarter
Hält's aus hier
Beiträge: 13

WindowsXP
Borland Delphi 7, Microsoft Visual Studio, Blitz3D, BlitzPlus
BeitragVerfasst: Di 11.09.07 19:55 
Hmmm... ich habe dann auch nochmal ne Frage. Wie kann ich Ereignis-prozeduren für irgendeinen der neu erstellten Button schreiben?
Diese soll aufgerufen werden, wenn ein beliebiger Button gedrückt wird..

Mfg
TheProgrammer

_________________
AMD Athlon XP 2100+ (1,73 GHz) | 768 MB RAM | NvIDIA GeForce 5200 FX | 160 GB Festplatte | WinXP Professional Edition
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 11.09.07 20:04 
Schreiben musst du diese natürlich vorheir. Du kannst sie aber zur Laufzeit zuweisen:

ausblenden Delphi-Quelltext
1:
Button.onClick := Form.OnButtonClick;					

_________________
Markus Kinzler.