Autor Beitrag
csigg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 20.07.05 10:30 
Ich hab eine form, und würde gerne alle Komponenten Enabled auf False setzen bis auf eine, also das ich praktisch nur noch diese Benutzen kann. Muss ich dass alles einzeln machen, oder geht das komplett?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 20.07.05 10:38 
Theoretische alle einzeln setzen. Das geht auch mit einer Schleife (-> FindComponent).

Tipp:
Nimm ein Panel, packe alle Komponenten darauf, bis auf die eine und disable das Panel.
patrick
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1481

WIN2k, WIN XP
D6 Personal, D2005 PE
BeitragVerfasst: Mi 20.07.05 11:41 
die schnellste art und weise ist die hier:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var i:Integer;
begin
  for i:=0 to Form1.ComponentCount-1 do
  begin
    (Form1.Components[i] as TControl).Enabled:=false;
  end;


am ende der schleife kannst du ja deine komponente, die nicht wieder deaktiviert werden soll wieder aktivieren. ( oder eine if abfrage in der schleife einfügen)

edit: was ich vergessen habe: wenn du nonvisual-VCL kompoenten verwendest (z.B. TServersocket) bekommst du ne exception.

hier die version die auch mit solchen komponenten funktioniert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var i:Integer;
begin
  for i:=0 to Form1.ComponentCount-1 do
  begin
    if Form1.Components[i] is TControl then
      (Form1.Components[i] as TControl).Enabled:=false;
  end;

_________________
Patrick
im zweifelsfall immer das richtige tun!!!
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 20.07.05 12:13 
Ich hab jetzt folgenden Quellcode:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
dbgAnwesend.Options := [dgEditing,dgTitles,dgRowLines];
          for i:=0 to frm_Verwalt.ComponentCount-1 do
          begin
               if frm_Verwalt.Components[i] is TControl then
                  (frm_Verwalt.Components[i] as TControl).Enabled:=false;
          end;
          dbgAnwesend.Enabled := true;
          varLabel.Enabled := true;
          varLabel.Caption := '[Edit-Modus verlassen mit ENTER]';
          flag := true;

Allerdings wird mir das dbgAnwesend nicht wirklich aktiviert, ich kann mit ihm nicht
arbeiten.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 20.07.05 12:18 
Ich vermute, dass die Komponente auf einer anderen liegt, zum Beispiel einem Panel, und dieses natürlich in der Schleife deaktiviert wurde.
Alle Child-Controls sind bei Enabled = False dann ebenfalls deaktiviert...
csigg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 20.07.05 12:21 
Das heisst das das DBGrid hat andere Eltern??
Also es liegt auf jedenfall auf einem TabSheet, hat jemand eine Idee wie das trotzdem gehen kann??
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 20.07.05 12:24 
Na ja, das PageControl aktivieren, ebenso das TabSheet. Und einfach nur in onChanging die Seitenauswahl verhindern.