From d72f3b73f6f55e77eb69cdf55b5771edaa1d0b15 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 18 Mar 2015 09:34:22 +0000 Subject: Two new form helper functions added to fpgApplication - GetFormByClassName() - GetFormByName() --- src/corelib/fpg_base.pas | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas index 4138dad9..d2d2e868 100644 --- a/src/corelib/fpg_base.pas +++ b/src/corelib/fpg_base.pas @@ -567,6 +567,8 @@ type function PrevModalForm: TfpgWindowBase; function RemoveWindowFromModalStack(AForm: TfpgWindowBase): Integer; procedure CreateForm(InstanceClass: TComponentClass; out Reference); + function GetFormByClassName(const AClassName: string): TfpgWindowBase; + function GetFormByName(const AName: string): TfpgWindowBase; function GetScreenWidth: TfpgCoord; virtual; abstract; function GetScreenHeight: TfpgCoord; virtual; abstract; function GetScreenPixelColor(APos: TPoint): TfpgColor; virtual; abstract; @@ -2500,6 +2502,36 @@ begin end; end; +function TfpgApplicationBase.GetFormByClassName(const AClassName: string): TfpgWindowBase; +var + i: integer; +begin + Result := nil; + for i := 0 to FormCount-1 do + begin + if Forms[i].ClassName = AClassName then + begin + Result := Forms[i]; + break; + end; + end; +end; + +function TfpgApplicationBase.GetFormByName(const AName: string): TfpgWindowBase; +var + i: integer; +begin + Result := nil; + for i := 0 to FormCount-1 do + begin + if Forms[i].Name = AName then + begin + Result := Forms[i]; + break; + end; + end; +end; + procedure TfpgApplicationBase.Terminate; var i: integer; -- cgit v1.2.3-70-g09d2