5-Minute-Snack: Display another form as a pop-up in TMS Web Core
Creating a second form is easy and has been shown in the last post. However, sometimes we might not want to take the other form to take up the whole screen but make it a pop-up window instead.
As it’s an amazing framework from TMS Software (disclaimer: this statement might be biased), making a new form to display as a pop-up is really easy:
begin LFrm := TFrmSettings.CreateNew( @AfterCreate ); // LFrm als Pop-Up festlegen LFrm.Popup := true; // Transparenz definieren LFrm.PopupOpacity := 0.2; LFrm.ShowModal( @AfterShowModal ) end;
The call to CreateNew is no different than for any other form. As an alternative, we just use the TWebForm constructor this time instead of TApplication. However, we can make the necessary property changes after calling the constructor. Be aware, that this is indeed possible in the same method. We do not have to do this in AfterCreate as it affects the object on the application side and has no impact on the creation for the window.
In order to make the new form a pop-up, we set the property Popup to true. We also specify an opacity for the form. 0 means it is completely transparent. 1 means no transparency at all.
We then show the form calling ShowModal. Yet again, this is possible as it tells the framework to show the form ‘when ready’. This means, AfterCreate will be called after creation and as soon as the form is ready to be shown, it will be shown. The method AfterShowModal will server as a means to get values from the pop-up window after its been closed.
That’s how easy it is to display a pop-up window using TMS Web Core.