Hello everyone.
Using the latest version of the TMS WebCore package it is not possible to change the caption of a modal window at run time.
I try to execute the following code:
FForm:= TFForm.Create(Parent, True, fbDialogSizeable,'HELLO ITALY');
TAwait.ExecP(FForm.Load());
FForm.Caption := 'HELLO WORLD';
TAwait.ExecP(FForm.Execute);
but the label display does not change. The label 'HELLO ITALY' is displayed or worse the one of the form created at design time.
I retested this here with the demo under Basics\MultiForm by inserting the code
procedure TForm1.WebButton1Click(Sender: TObject);
var
newform: TForm2;
begin
newform := TForm2.Create(Self);
newform.Caption := 'Child form';
newform.Popup := WebRadioGroup1.ItemIndex <> 0;
case WebRadioGroup1.ItemIndex of
2: newform.Border := fbDialog;
3: newform.Border := fbDialogSizeable;
end;
// used to manage Back button handling to close subform
window.location.hash := 'subform';
// load file HTML template + controls
TAwait.ExecP<TForm2>(newform.Load());
// init control after loading
newform.frm2Edit.Text := WebEdit1.Text;
newform.Caption := 'New caption'; // <------- CODE ADDED
try
// excute form and wait for close
TAwait.ExecP<TModalResult>(newform.Execute);
ShowMessage('Form 2 closed with new value:"'+newform.frm2Edit.Text+'"');
WebEdit1.Text := newform.frm2Edit.Text;
finally
newform.Free;
end;
end;
and this works as expected here. I tested it for the different form types in the demo.
What is different in your app?
unit UEditCategoria;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, Vcl.StdCtrls, WEBLib.StdCtrls, Vcl.Controls,
Archivi, Data.DB, WEBLib.DB, WEBLib.DBCtrls, XData.Web.Client;
type
TFEditCategoria = class(TWebForm)
lblDescrizione: TWebLabel;
btnAnnulla: TWebButton;
btnOK: TWebButton;
edtDescrizione: TWebDBEdit;
WebDataSource1: TWebDataSource;
private
{ Private declarations }
public
{ Public declarations }
[async]
class procedure ShowEditCategoria(Parent: TComponent; ID: LongInt);
end;
implementation
{$R *.dfm}
uses
Main;
{ TFEditCategoria }
class procedure TFEditCategoria.ShowEditCategoria(Parent: TComponent;
ID: LongInt);
var
FEditCategoria: TFEditCategoria;
[async]
procedure OnOpenCATEG_MAGAZZINO(Response: TXDataClientResponse);
var
Caption : string;
begin
Dati.CATEG_MAGAZZINO.SetJsonData(Response.Result);
Dati.CATEG_MAGAZZINO.Open;
if ID <> -1 then
Caption := 'Modifica categoria ' +
Dati.CATEG_MAGAZZINO.FieldByName('CATEGORIA').AsString
else
Caption := 'Nuova categoria';
FEditCategoria := TFEditCategoria.Create(Parent, True, fbDialogSizeable);
try
TAwait.ExecP<TFEditCategoria>(FEditCategoria.Load());
FEditCategoria.Caption := Caption;
if ID <> -1 then
Dati.CATEG_MAGAZZINO.Edit
else
begin
Dati.CATEG_MAGAZZINO.Append;
Dati.CATEG_MAGAZZINO.FieldByName('CODICE').AsString := '';
Dati.CATEG_MAGAZZINO.FieldByName('IMP').AsInteger := 0;
end;
TAwait.ExecP<TModalResult>(FEditCategoria.Execute);
if (FEditCategoria.ModalResult = mrOK)
and (Trim(FEditCategoria.edtDescrizione.Text) <> '') then
begin
Dati.CATEG_MAGAZZINO.Post;
Dati.CATEG_MAGAZZINO.ApplyUpdates;
TFMain(Parent).CreaAlbero;
end
else
Dati.CATEG_MAGAZZINO.Cancel;
finally
FEditCategoria.Free;
end;
// Non si può chiamare perchè altrimenti ottengo un exception error
// se faccio ApplyUpdates
// Dati.CATEG_MAGAZZINO.Close;
end;
begin
if not Dati.EDSqlServiceConn.Connected then
await(Dati.EDSqlServiceConn.OpenAsync);
Dati.GenericEntity.List('CATEG_MAGAZZINO','$filter=ID eq '+ID.ToString,@OnOpenCATEG_MAGAZZINO);
end;
end.
With this code the form caption does not change: it either remains empty or the one inserted in design time remains.
From just reading this code, I cannot say much.
Please isolate this and send a sample source project without external dependencies that allows us to reproduce this here.