Atozed Forums

Full Version: TContentForm always create a new instance
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hellow,

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

has the UseExistingInstance property, more is read-only.

Thanks All.
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.