Entwickler-Ecke

Grafische Benutzeroberflächen (VCL & FireMonkey) - Alle graphisch. Kompos eines Formulars mit Frames ermitteln?


winx - Mi 13.07.05 08:14
Titel: Alle graphisch. Kompos eines Formulars mit Frames ermitteln?
Hallo,

ist es irgendwie möglich alle graphischen Komponenten eines Formulars mit Frames zu ermitteln?

Ich habe ein Form, mit einem Frame. In diesem Frame liegen wieder mehrere Frames. Nun möchte ich beim Programmstart <u>alle</u> graphischen Komponenten finden und deren Größe auf die jeweilige Auflösung anpassen (incl Schrift, Breite, Höhe)

Ist das möglich, oder muß ich (zumindest in jedem Frame) eine Prozedur schreiben, die das übernimmt?

Danke,
winx


bombardir - Mi 13.07.05 10:33


Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
function IsYourChild(AComponent,AVal: TControl): boolean;
var
   Res   : boolean;
   P     : TControl;
begin
   Res:=false;
   if AVal<>nil then
   begin
      P:=AVal.Parent;
      while (P<>niland (not Res) do
      begin
         Res:=(P=AComponent);
         P:=P.Parent;
      end
   end;
   Result:=Res;
end;

...

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
var
   i        : integer;
   F        : TForm;
   SomeComp : TComponent;
   Frame    : TGroupBox;
begin
   F:=Self; //Form1 usw.
   Frame:=F.GroupBox3;

   for i:=0 to F.ComponentCount-1 do
   begin
      SomeComp:=F.Components[i];
      
      if IsYourChild(Frame,SomeComp) then 
      begin
         // da eine Aktion für Komponente "SomeComp", 
         // die innerhalb "Frame" sich befindet, egal, ob
         // dazwischen noch verschachtelte Frames liegen
      end;
   end;
end;


winx - Mi 13.07.05 10:55

Danke, aber kannst du mir den source noch kurz erläutern?

Muß ich den nur im Hauptform ,oder in jedem Form anwenden?

thx