AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Form + Frame = ActiveContol = nil

Ein Thema von haentschman · begonnen am 2. Nov 2016 · letzter Beitrag vom 4. Nov 2016
 
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.572 Beiträge
 
Delphi 12 Athens
 
#4

AW: Form + Frame = ActiveContol = nil

  Alt 2. Nov 2016, 21:11
Man kann sich auch selber ein ActiveControl schreiben, welches auf die TopForm weiterleitet.
Delphi-Quellcode:
type
  TActiveCompHelper = class helper for TCustomForm
  private
    function GetMyActiveControl: TWinControl;
    procedure SetMyActiveControl(const Value: TWinControl);
  public
    property MyActiveControl: TWinControl read GetMyActiveControl write SetMyActiveControl;
  end;

function TActiveCompHelper.GetMyActiveControl: TWinControl;
{begin
  // nur die eigene Form
  Result := GetParentForm(Self, True).ActiveControl;
  if GetParentForm(Self, False) <> GetParentForm(Result, False) then
    Result := nil;
end;}

var
  P: TWinControl;
begin
  // SubForms erlaubt
  Result := GetParentForm(Self, True).ActiveControl;
  P := GetParentForm(Result, False);
  while Assigned(P) and (P <> Self) do
    Result := GetParentForm(P.Parent, False);
  if not Assigned(P) then
    Result := nil;
end;

procedure TActiveCompHelper.SetMyActiveControl(const Value: TWinControl);
begin
  GetParentForm(Self, True).ActiveControl := Value;
end;
Will man aber nur wissen, was das ActiveControl ist, egal wo, um es mit einer Componente der eigenen Form zu vergleichen, dann kann man auch global werden.
if Screen.ActiveControl = {Self.}Edit1 then ...
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
 

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:56 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz