Cristiano:
That You want is not possible to made in the Way that you show there.
Thinks that allways a Web Application is a Client/Server app.
The page request a response from the server and the server responds the request.
I you want to show a wait when a form is created and quit the show when the form is done, you cannot do this in a single event handler, because:
1) The page request the creation of a form sending a Ajax request to the server.
2) The server executes the event handler. Until the server is not execute totally the event, client only wait to server response.
3) The server send javascript commands to the page as response of the page request.
4) The client executes the javascript and as consequence the form is showed on the page.
The best way to do this is using a custom ajax event manager or modifing the actual to show a "wait cursor" until the server responds request.
Y made a simulation of this using TUniScreenMask setting a screen mask targeting at no one (assume all page) to all buttons and keypress events handlers via a generic routine.
There is the code (sorry spanish):
{ Configura las máscaras de espera y las grillas de los formularios o frames }
procedure ConfiguraForm(p_formFrame: TWinControl; p_formParent: TfrmBase);
var
i: Integer;
procedure CrearMascara(p_componente : TComponent);
var
l_mask : TUniScreenMask;
begin
{ Crear la máscara }
l_mask := TUniScreenMask.Create(p_formParent);
p_formParent.InsertComponent(l_mask);
with l_mask do
begin
AttachedControl := p_componente;
DisplayMessage := 'Procesando...';
end; // with
end;
procedure ProcesaComponente(p_component: TComponent);
var
i: Integer;
l_panel: TUniPanel;
l_page: TUniPageControl;
l_tab: TUniTabSheet;
l_edit: TUniEdit;
l_frame: TFrame;
l_grid: TUniDBGrid;
l_cds : TClientDataSet;
begin
{ Recorrer todos los controles contenidos }
if p_component is TUniPanel then
begin
l_panel := TUniPanel(p_component);
for i := 0 to l_panel.ControlCount - 1 do
ProcesaComponente(l_panel.Controls[i]);
end
else if p_component is TUniPageControl then
begin
l_page := TUniPageControl(p_component);
//CrearMascara(l_page);
for i := 0 to l_page.PageCount - 1 do
ProcesaComponente(l_page.Pages[i]);
end
else if p_component is TUniTabSheet then
begin
l_tab := TUniTabSheet(p_component);
for i := 0 to l_tab.ControlCount - 1 do
ProcesaComponente(l_tab.Controls[i]);
end
else if p_component is TFrame then
begin
l_frame := TFrame(p_component);
for i := 0 to l_frame.ControlCount - 1 do
ProcesaComponente(l_frame.Controls[i]);
end
else if p_component is TUniButton then
CrearMascara(p_component)
else if p_component is TUniBitBtn then
CrearMascara(p_component)
else if p_component is TUniEdit then
begin
l_edit := TUniEdit(p_component);
if l_edit.CharEOL = #13 then
CrearMascara(p_component);
end
else if p_component is TUniDBGrid then
begin
l_grid := TUniDBGrid(p_component);
l_grid.WebOptions.Paged := false;
l_grid.WebOptions.LoadMask := True;
l_grid.WebOptions.LoadMaskMsg := 'Procesando...';
end
else if p_component is TClientDataSet then
begin
l_cds := TClientDataSet(p_component);
l_cds.OnReconcileError := p_formParent.cdsReconcileError;
end; // if
end;
begin
for i := 0 to p_formFrame.ComponentCount - 1 do
ProcesaComponente(p_formFrame.Components[i]);
end;
Then when a button is pressed a wait shows until the button code is executed.
I hope be ussefull.