Autor Beitrag
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 19:06 
Hi,

ich hab das Tut, von dem ihr mir den Link gegeben habt, dursucht, hab mit Google gesucht und hier im Forum gesucht, aber nix gefunden:

Ich hab mehrere Buttons "Button1", "Button2", ...
Nun hab ich noch einen Button (nenn in jetzt hier mal, "ABC" und wenn ich auf den klick, soll immer ein Button mehr Enabled werden.
Also:

1. Button1 und Button2 sind "Enabled = False"
2. Ich klick auf den Button "ABC"
3. Button1 "Enabled = True", Button2 "Enabled = False"
4. Ich klick nochmal auf den Button "ABC"
5. Button1 "Enabled = True", Button2 "Enabled = True"

Hab schon versucht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var i : integer;
begin
inc(i)
button(i).enabled := true;
end


Das geht aber nicht.
Da kommt dann:

Zitat:
Undefinierter Bezeichner 'Button'.


Könnt ihr mir bitte sagen, wie ich das machen kann?


THX!
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Fr 02.04.04 19:20 
hi,

Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT


raziel

_________________
JSXGraph
GTA-Place Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 19:21 
Danke!
Man muss nur den richtigen Begriff suchen :D
Girgl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 281


D6 Enterprise
BeitragVerfasst: Fr 02.04.04 19:22 
hat sich erledigt...
GTA-Place Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 19:34 
Allerdings find ich das:

ausblenden Delphi-Quelltext
1:
(FindComponent('Edit' + IntToStr(i)) as TEdit).Text					


Ich ersetze das 'Edit' durch 'Button' aber dann stimmt ja das "as TEdit" nicht, denn wenn ich es lasse, bekomm ich einen Zugriffsfehler, lasse ich es weg kommt "Undefinierter Bezeichner 'Enabled'."
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Fr 02.04.04 19:41 
wie wärs mit

ausblenden Delphi-Quelltext
1:
(FindComponent('Button' + IntToStr(i)) as TButton).Enabled					



raziel

_________________
JSXGraph
GTA-Place Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 19:42 
Dann bekomm ich ne Zugriffsverletzung!
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Fr 02.04.04 19:47 
Dann existiert "Button(i)" nicht!
Die Namen der buttons müssen schon "Button1", "Button2" , etc sein!
Auch darf "i" nicht größer sein als die Anzahl der Buttons. Mit was wird i überhaupt initialisiert? mit 1 oder mit 0?


raziel

_________________
JSXGraph
GTA-Place Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 19:49 
ausblenden Delphi-Quelltext
1:
i := 0					


Und "+1" oder "inc(i)" wäre es 1 und Button1 gibts.
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Fr 02.04.04 19:50 
probiers mal mit
ausblenden Delphi-Quelltext
1:
i:=1;					


//edit: vergiss es, i wird ja vor fincomponent geinct...


raziel

_________________
JSXGraph
GTA-Place Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 19:53 
Ne, auch Zugriffsverletzung.
Hier mal der Quelltext:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
     x : String;
     i : Integer;
begin
     i := 1;
     inc(i);
     X := AdressLabel.Caption;
     Favoriten.FavoritenMemo.Lines.Add(x);
     (FindComponent('Button' + IntToStr(i)) as TButton).Enabled := True
end;
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Fr 02.04.04 19:55 
is da wirklich kein strichpunkt nach dem true?

_________________
JSXGraph
GTA-Place Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 20:01 
Da is keiner, aber auch wenn da einer is, gehts net :roll:
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Fr 02.04.04 20:04 
kommentier das ganze mit dem "x" weg und probiers nochmal:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
//     x : String;
     i : Integer;
begin
     i := 1;
     inc(i);
//     X := AdressLabel.Caption;
//     Favoriten.FavoritenMemo.Lines.Add(x);
     (FindComponent('Button' + IntToStr(i)) as TButton).Enabled := True
end;

der findcomponent code müsste eigentlich in ordnung sein...


raziel

_________________
JSXGraph
GTA-Place Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 20:07 
Und wieder ne Zugriffsverletzung.
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Fr 02.04.04 20:10 
:autsch:

_________________
JSXGraph
GTA-Place Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 20:13 
Zitat:
Die Methode Release entfernt das Formular und gibt den von ihm belegten Speicher frei.

procedure Release;

Beschreibung

Mit Release können Sie das Formular aus dem Speicher entfernen.
Release ähnelt der Methode Free, gibt aber das Formular erst frei, nachdem die Ausführung der Ereignisbehandlungsroutinen des Formulars und seiner untergeordneten Komponenten beendet ist. In allen Ereignisbehandlungsroutinen sollte Release statt Free verwendet werden, um Exceptions aufgrund von Zugriffsverletzungen zu vermeiden.


Zitat aus der Delphi-Hilfe.
Bringt das was?
Und wie wend ich es an?
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 02.04.04 20:26 
Ich fasse mal euren Dialog zusammen:

raziel hat folgendes geschrieben:
Mit was wird i überhaupt initialisiert? mit 1 oder mit 0?

GTA-Place hat folgendes geschrieben:
Und "+1" oder "inc(i)" wäre es 1 und Button1 gibts.

Schön und gut, aber das im Code sieht nicht aus wie ´ne Null:
GTA-Place hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
     x : String;
     i : Integer;
begin
     i := 1; // <-- das soll eine Null sein?
     inc(i); // <-- +1
     X := AdressLabel.Caption;
     Favoriten.FavoritenMemo.Lines.Add(x);
     (FindComponent('Button' + IntToStr(i)) as TButton).Enabled := True
end;

Könnte es evtl. daran liegen?
GTA-Place Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Fr 02.04.04 20:28 
Nein, hab 0 und 1 gehabt.
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 02.04.04 20:29 
PS: Folgendes kleine Beispiel funktioniert bei mir definitiv - der Button, der sich selbst abschaltet:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  (FindComponent('Button1') as TButton).Enabled := false;
end;

Ich könnte auch vorher die Eins an eine Integer-Variable übergeben und mit "inttostr" arbeiten. Das Ergebnis wäre das gleiche.