Autor Beitrag
winx
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 249



BeitragVerfasst: Mi 13.07.05 08:14 
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
Hält's aus hier
Beiträge: 6

Windows
Delphi 6 +FastReport+DOA+DevExpress, Oracle, PL/SQL
BeitragVerfasst: Mi 13.07.05 10:33 
ausblenden 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;

...
ausblenden 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 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 249



BeitragVerfasst: 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