Try these sequences of steps:
1.
2.
procedure TUniForm1.UniFormCreate(Sender: TObject);
var
EventoJs: string;
begin
// if FHideOption = True then
// begin
// // None
// end
// else
// begin
// // Creo el evento para el javascript
// EventoJs := 'function window.afterCreate(sender){sender.addTool([{'+
// 'xtype: ''button'','+
// 'text: ''Test button'','+
// 'iconCls: ''myicon'','+
// 'handler:function(){'+
// 'this.up(''window'').mask(''Wait...'');'+
// 'ajaxRequest(this.up(''window''),''test'',[]);'+
// '}}]);}';
//
// // Agrego al formulario
// Self.ClientEvents.UniEvents.Values['window.afterCreate'] := EventoJs;
// end;
end;
procedure TUniForm1.UniFormReady(Sender: TObject);
begin
if not FHideOption then
begin
JSInterface.JSCall('header.insert', [1, UniButton1.JSControl], WebForm.JSWindow);
end;
end;