it is possible to use Webcore to map the behavior of ShowModal from Delphi
without having to create the form over and over again
Set query text 1
if Form1.Showmodal with query Text 1 = mrOk
Set query text 2
if Form1.Showmodal with query Text 2 = mrOk
......
else
Set query text 3
if Form1.Showmodal with query Text 3 = mrOk
......
.......
I looked at the TMSWeb_Multiform demo, but that doesn't get me anywhere
because I got to recreate the form over and over again
newform: = TForm2.Create (Self);
window.location.hash: = 'subform';
await (TForm2, newform.Load ());
await (TModalResult, newform.Execute);
But I would like a version with which I can generate the form once and then call up the same thing over and over again with other Vars
As demo Demo\Basics\MultiForm demonstrates and calling
await(TModalResult, newform.Execute);
repeatedly
Implementation according to demo
procedure TForm1.WebButton1Click(Sender: TObject);
var
Result : byte;
NextQuery : byte;
begin
Result := mrOk;
newform := TForm2.Create(Self);
newform.Caption := '';
newform.Popup := true;
newform.Type := Query1;
await(TForm2, newform.Load());
try
await(TModalResult, newform.Execute);
ShowMessage('Form 2 closed with new value:"'+newform.frm2Edit.Text+'"');
Result .Text := newform.Result;
finally
newform.Free;
end;
if Result = mrOk then
NextQuery := Query2
else NextQuery := Query3;
newform := TForm2.Create(Self);
newform.Caption := '';
newform.Popup := true;
await(TForm2, newform.Load());
try
await(TModalResult, newform.Execute);
ShowMessage('Form 2 closed with new value:"'+newform.frm2Edit.Text+'"');
Result := newform.Result;
finally
newform.Free;
end;
end;
with showmodal
With Delphi, the form is already generated at the start
procedure TForm1.WebButton1Click(Sender: TObject);
var
Result : byte;
begin
Result := mrOk;
Form2.Type := Query1;
if Form2.ShowModal = mrOk then
Form2.Type := Query2
else Form2.Type := Query3;
Form2.ShowModal;
end;
Now my question,
is there an intermediate variant with which I don't always have to recreate the Form2, so we do at Delphi
I tried the:
At first Time Create the Form2, newform.Free;
leave out and then the form with await (TModalResult, newform.Execute);
to activate, but that does not work.
The other problem is that I can not outsource the whole thing in a procedure, otherwise the async will no longer work.
I do not understand from your code what you try to do.
I do not see in this case you call form.Execute more than once..?
I'll try by description.
I should call several queries in "MouseDown" in the same "Down".
Everything is possible with the example from "MultiForm".
Well, the problem is that the "MausUp" function is processed completely asynchronously as soon as I define the "MausDown" function as [async]. This "MausUp" function also contains functions that should only be processed after the final handling of "MausDown".
Flowchart:
MouseDown (Form1)
Query1 -> Result (Form2)
Query2 -> Result (Form2)
Input (Form3)
MausUp (Form1)
In delphi this works with Showmodal calling Form2 and Form3
In Webcore I can't do this because of the async
I see nowhere you use promises & await , which could be a solution to your problem?
Here is the difference
When the mouse is down on the image, a mouseup is always triggered in Delphi when open a form. There is no mouseup trigger in TMSWebCore.
The down / up reactions in Delphi and TMSWebCore are the same at the button.
It's only different on the image.
Since I am rewriting the source from a Delphi application to a TMSWebCore Application.
I've now rewritten it so that it also works with the TMS variant.
Is so ok for me.