Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Parent rausfinden (https://www.delphipraxis.net/103890-parent-rausfinden.html)

Moony 23. Nov 2007 15:28


Parent rausfinden
 
Hallo zusammen,

ich füge zur Laufzeit ein Frame in eine Form mehrmals hinzu. Das funktioniert soweit wunderbar, mein Problem ist das Killen dieser. Wenn ich alle wieder freimache ist alles ok. Will ich jedoch ein Frame freimachen, bei dem ich gerade eine Aktion gemacht habe, geht das nicht, weil ich irgendwie nicht das richtige Parent von der untergeordneten Komponente bekomme.
Ich habe das foglendermaßen versucht:

Delphi-Quellcode:
var
  fr : TSearchFields;
  i : Integer;
begin
...
  fr := (cmbSearch.Parent) as TSearchFields; // diese Komponente ist dem TSearchFields untergeordnet und wurde gerade angewählt
  for i := 0 to fmSearch.GroupSearchFields.ControlCount - 1 do
  begin
    if fmSearch.GroupSearchFields.Controls[i] is TSearchFields then // das ist mein Frame statisch generiert
    begin
      myFrame := fmSearch.GroupSearchFields.Controls[i] as TSearchFields; // myFrame:TSearchFields; wird dynamisch erzeugt
      if myFrame.Name = fr.Name then
      begin
        myFrame.Free;
        Exit;
      end;
    end;
  end;
...
end;

Sprich: Ich habe in der Combobox einen bestimmten Eintrag ausgewählt und möchte das Frame von dieser Combobox wieder entfernen.

Danke im Voraus.

Gruß, Moony

Deep-Sea 26. Nov 2007 07:36

Re: Parent rausfinden
 
Dein Problem verstehe ich nicht so ganz. Du willst von einen gegebenen Control auf das Frame schießen, auf das sich das Control befindet?

Vlt. hilft dir das?!
Delphi-Quellcode:
function GetParentFrame(AControl: TControl): TFrame; // Ungetestet
begin
  While not (Control is TFrame) and (AControl.Parent <> nil) do
    Control := Control.Parent;
  If Control is TFrame then Result := TFrame(Control)
    else Result := nil;
end;
:?

EWeiss 26. Nov 2007 07:47

Re: Parent rausfinden
 
Zitat:

Zitat von Moony
Hallo zusammen,

Sprich: Ich habe in der Combobox einen bestimmten Eintrag ausgewählt und möchte das Frame von dieser Combobox wieder entfernen.

Danke im Voraus.

Gruß, Moony

das ist unmöglich solange ein zugriff auf die combo stattfindet schließlich ist das frame
dann noch immer ein bestandteil dieser wenn du es als parent in die combo gelegt hast.

Zumindest habe ich das so verstanden ;)

Also es darf kein zugriff auf die combo stattfinden dann kannst du das frame auch entfernen.

gruss


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:01 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz