Blog Options
Archive
<< April 2024 >>-
Wednesday 24
- Expanding the StellarDS.io tooling -
Monday 22
- Easy Guide to Building a Pexels Gallery App with TMS WEB Core -
Wednesday 17
- New free component for sophisticated file uploads with TMS WEB Core -
Tuesday 16
- Closing the gap with TMS FNC UI Pack new additions -
Thursday 11
- Unveiling the Latest Enhancements in TMS VCL UI Pack -
Friday 5
- TMS components and Delphi and C++Builder 12.1 -
Wednesday 3
- Customizing the login page of your application using TMS Sphinx
- A Python library for using StellarDS.io effortlessly
- Introducing: How it Works with Holger - Building a Pexels gallery app with TMS WEB Core video series
- TMS FNC Cloud Pack with StellarDS.io backend: unparalleled productivity in VCL & FMX
Authors
- Bernard Roussely (1)
- Wagner Landgraf (82)
- Roman Yankovsky (2)
- Bart Holvoet (27)
- Aaron Decramer (18)
- Pieter Scheldeman (99)
- Nancy Lescouhier (32)
- Adrian Gallero (33)
- Bruno Fierens (404)
- Marcos Douglas B. Santos (5)
- Wagner R. Landgraf (1)
- Bradley Velghe (16)
- Bernard (2)
- Andrew Simard (86)
- Holger Flick (15)
- Gjalt Vanhouwaert (30)
- Tunde Keller (22)
- Masiha Zemarai (119)
Blog
All Blog Posts | Next Post | Previous PostTMS WEB Core v1.2 tips & tricks part 3 : Handling multiple forms with TApplication
Bookmarks:Friday, June 21, 2019
The class TApplication has been part of Delphi since its inception. TMS Web Core tries to make as little changes to your development as possible. Thus, it provides its own method helper class to TApplication to provide additional functionality that will help you to control and react to events in your web application.TApplication = class(TControl) private public // function CreateNewForm(AInstanceClass: TFormClass): TCustomForm; overload; function CreateNewForm(AInstanceClass: TFormClass; AElementID: string): TCustomForm; overload; procedure CreateForm(AInstanceClass: TFormClass; var AReference); overload; procedure CreateForm(AInstanceClass: TFormClass; AElementID: string; var AReference); overload; procedure CreateForm(AInstanceClass: TFormClass; AElementID: string; var AReference; AProc: TFormCreatedProc); overload; procedure CreateForm(AInstanceClass: TDataModuleClass; var AReference); overload; procedure CreateForm(AInstanceClass: TFormClass; AElement: TJSHTMLElement; var AReference); overload; property ActiveForm: TCustomForm read FActiveForm; property MainForm: TCustomForm read FMainForm; end;
You have plenty of methods to create a new form. These methods have been extended to fulfill the needs of the asynchronous nature of the web. To be precise, every method overs a callback that can be used to implement code after the form has been created. Of course, every form has its own OnCreate event, but you might want to execute code that is not part of the form after creation. E.g. passing values to the new form.
procedure TForm1.ShowSettings; var LFrm : TFrmSettings; // called after form is closed procedure AfterShowModal(AValue: TModalResult); begin // evaluate AValue and get values from form ... end; // will be called after form has been created procedure AfterCreate(AForm: TObject); begin // pass values to form referenced in AForm ... end; begin LFrm := TFrmSettings.CreateNew( @AfterCreate ); LFrm.ShowModal( @AfterShowModal ) end;
The example above is taken from a TMS Web Core application that features a form with settings. The form is being created and shown. Its values for initialization are passed in AfterCreate. Changes can be persisted in AfterShowModal.
Talking about multiple forms in an app. You can always query the active form that is being displayed using:
LActiveForm := Application.ActiveForm;
Further, to determine the main form of the application use:
LMainForm := Application.MainForm;
Holger Flick
Bookmarks:
This blog post has not received any comments yet.
All Blog Posts | Next Post | Previous Post