When creating a popup form, e.g. like so:
Var F : TWebForm;
F := AFormClass.Create(AParent,True,ABorderStyle,ATitle);
then afterwards property ElementHandle
always returns Nil. This is because GetElementHandle
is implemented like this
function TCustomForm.GetElementHandle: TJSHTMLElement;
begin
if FPopup then
Result := inherited GetElementHandle
else
Result := TJSHTMLElement(FormContainerElement);
end;
and, if FPopup is true, inherited GetElementhandle
returns Nil as well.
In fact, during form creation in
TApplication.CreateNewForm(AForm: TCustomForm; HTML: string)
...
span := TJSHTMLElement(document.createElement('DIV'));
...
AForm.FPopupElement := span;
the created element is assigned to a private member named FPopupElement
that unfortunately never gets published.
The function TCustomForm.GetElementHandle: TJSHTMLElement
should be fixed to this respect!
In the meantime, in order to get hold of the "Elementhandle" of a popup form, a helper like this can be used:
Type
TWebFormHelper = Class helper for TWebForm
Public
Function Eh : TJSHTMLElement;
End
Function TWebFormHelper.Eh : TJSHTMLElement;
Begin
If Self.Popup then
{$IFDEF PAS2JS}
ASM
Result = this.FPopupElement
END
{$ELSE}
Result := Nil
{$ENDIF}
Else
Result := Self.ElementHandle
End;