Atozed Forums
TContentForm always create a new instance - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: TContentForm always create a new instance (/thread-1071.html)



TContentForm always create a new instance - oulijrasec - 05-10-2019

Hellow,

how do I get TContentForm to always create a new instance?

has the UseExistingInstance property, more is read-only.

Thanks All.


RE: TContentForm always create a new instance - Alexandre Machado - 05-10-2019

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.