Posts: 7
Threads: 3
Joined: May 2019
Reputation:
0
Hellow,
how do I get TContentForm to always create a new instance?
has the UseExistingInstance property, more is read-only.
Thanks All.
Posts: 2,174
Threads: 184
Joined: Mar 2018
Reputation:
79
Location: Auckland, New Zealand
05-10-2019, 10:53 PM
(This post was last modified: 05-10-2019, 10:55 PM by Alexandre Machado.)
Default for UseExistingInstance is True.
Besides that, you can:
- Create a descendant class of TContentForm and change the behavior at will
- Change mUseExistingInstance (it is protected not private), as:
type
TContentFormAccess = class(TContentForm)
procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);
var
LContentHandler: TContentForm;
begin
LContentHandler := TContentForm.Create(TMyIWForm);
TContentFormAccess(LContentHandler).mUseExistingInstance := False;
THandlers.Add('', 'myaddress.html', LContentHandler);
end;
Have in mind that when UseExistingInstance is True, the session will search for an existing instance with the same class name, so you must not have 2 forms with the same class name instantiated.
In case UseExistingInstance is False, you are responsible for form destruction otherwise they will accumulate and start consuming system resources, until the session is terminated.