Autor Beitrag
Tilo
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Di 04.11.03 07:18 
Ich habe ein Problem: :oops:

Ich möchte eine Reihe von Buttons erzeugen und dass während der Laufzeit. Ich kann die Buttons zwar erzeugen, aber sie werden nicht angezeigt.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.startClick(Sender: TObject);
var
fels: array [1..256] of Tbutton;
i:integer;
begin
for i:=2 to 256 do
begin
 fels[i]:=TButton.Create(form1);
 fels[i].width:=40;
 fels[i].height:=40;
 fels[i].top:=i;
 fels[i].left:=i;
 fels[i].visible:=true;
 fels[i].caption:='JA';
end;
end;

end.

Der Code ist Fehlerfrei. Trotzdem werden die Buttons nicht angezeigt auf dem Formular. :shock:

Danke im Voraus

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
barfuesser
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 324



BeitragVerfasst: Di 04.11.03 07:29 
Du mußt den Parent noch setzen. Der Parent ist das Steuerelement, welches den Button anzeigen soll.

barfuesser
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 04.11.03 09:23 
In deinem Fall also:
ausblenden Delphi-Quelltext
1:
2:
3:
fels[i]:=TButton.Create(form1); 
fels[i].Parent := form1;
fels[i].width:=40;

Gruß
Tino
Tilo Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Di 04.11.03 16:27 
Titel: Danke
:arrow: Es funktioniert. Vielen Dank an Tino. :dance:


:twisted: das so etwas einfaches nicht in der Hilfe von Delphi steht :evil:
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Di 04.11.03 19:28 
Hallo,

dass das nicht in der Hilfe steht, stimmt so nicht. Folgend ein Ausschnitt:

Zitat:

Beispiel: Testen von noch nicht installierten Komponenten

Nehmen wir an, Sie wollen eine Komponente vom Typ TMyControl testen, die in einer Unit namens MyControl deklariert ist. Erzeugen Sie ein neues Projekt und führen Sie die beschriebenen Schritte durch. Am Ende sollten Sie eine Formular-Unit erhalten, die etwa so aussieht:

unit Unit1;

interface

uses

SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, MyControl; { 1. NewTest der uses-Klausel hinzufügen }

type

TForm1 = class(TForm)
procedure FormCreate(Sender: TObject); { 3. Behandlungsroutine für OnCreate zuweisen }

private

{ Private declarations }
public
{ Public Declarations }
MyControl1: TMyControl1; { 2. Objektfeld einfügen }
end;

var

Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);

begin
MyControl1 := TMyControl.Create(Self); { 4. Komponente erzeugen }
MyControl1.Parent := Self; { 5. Eigenschaft Parent setzen,
falls Komponente ein Steuerelement ist}
MyControl1.Left := 12; { 6. Weitere Eigenschaftswerte
... zuweisen wird nach Bedarf
fortgesetzt }
end;
end.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Tilo Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Sa 08.11.03 21:53 
Titel: ups
:oops: Schuldigung. :oops:
Ich meinte ja nur, das der Hinweis, das bei parent form1 eingesetzt werden muss nicht bei der Erklärung des TButton.Create als Hinweis steht. :oops:
Tilo Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Mo 10.11.03 20:06 
Titel: Und die Farbe
:oops: Ok das mit dem erzeugen der Button klappt ja schon mal, aber ich kann die Farbe über den Befehl tbutton.brush.Color:= nicht ändern. Das Verändern der Captions funktioniert aber.
Wie kann ich die Farbe von Buttons ändern?
obbschtkuche
Gast
Erhaltene Danke: 1



BeitragVerfasst: Mo 10.11.03 20:19 
Von standardbuttons garnicht.
aber auf [url]www.swissdelphicenter.ch[/url] gibt es einen Tipp dazu.

hier:
www.swissdelphicente...showcode.php?id=1100
ErnestoChe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 528

Win 2000 pro, CRUX 2.0
Delphi 6 Pers, Open K3
BeitragVerfasst: Mo 10.11.03 20:22 
Hi,

beim TButton kann man die Farbe nicht ohne weiteres ändern. Du kannst dir entweder selber eine Komponente ableiten oder eine entsprechende runterladen, z.b. bei Torry.

MFG

- Ernesto -
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 11.11.03 09:44 
Titel: Re: Und die Farbe
Tilo hat folgendes geschrieben:
Wie kann ich die Farbe von Buttons ändern?

Neue Frage - neues Topic!

Also bitte ein neues Topic erstellen.

Gruß
Tino
Dieses Thema ist gesperrt, Du kannst keine Beiträge editieren oder beantworten.

Das Thema wurde von einem Team-Mitglied geschlossen. Wenn du mit der Schließung des Themas nicht einverstanden bist, kontaktiere bitte das Team.