[Pas2js] TMS Web Clone
warleyalex
warleyalex at yahoo.com.br
Fri Mar 2 04:57:14 CET 2018
Almost there. I was able to create some visual web "dummy" components
(TWebLabel, TWEBEdit, TWebButton, TWebComboBox and TWebMemo) and drop the
components into the form.
----------------------------------------------
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
SysUtils, Classes, JS, Web,
WEBLib.Graphics, WEBLIB.Controls, WEBLib.StdCtrls, WEBLib.ExtCtrls,
WEBLib.Forms,
WEBLib.Dialogs;
type
TForm1 = class(TWebForm)
private
{ Private declarations }
WebLabel1: TWebLabel;
WebEdit1: TWebEdit;
WebButton1: TWebButton;
WebMemo1: TWebMemo;
WebComboBox1: TWebComboBox;
WebPanel1: TWebPanel;
WebLabel2: TWebLabel;
WebImageControl1: TWebImage;
public
{ Public declarations }
procedure LoadDFMValues; override;
procedure WebButton1Click(Sender: TObject);
procedure WebComboBox1Change(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.LoadDFMValues;
begin
inherited;
LoadDFMFromStream('Unit1.dfm');
end;
procedure TForm1.WebButton1Click(Sender: TObject);
begin
console.log('button clicked');
WebComboBox1.Items.Add(WebEdit1.Text);
WebComboBox1.ItemIndex := WebComboBox1.Items.Count - 1;
WebMemo1.Lines.Add(WebEdit1.Text);
end;
procedure TForm1.WebComboBox1Change(Sender: TObject);
begin
WebLabel1.Caption := WebComboBox1.Items[WebComboBox1.GetItemIndex];
end;
end.
----------------------------------------------
Now I have to implement the method
TForm1.LoadDFMValues/LoadDFMFromStream('Unit1.dfm').
I bet TMS Web is using GExpert trick called "Components to Code" to dump the
content into the LoadDFMValues JS method. I don't know, it should be
possible to parse the DFM/LFM at runtime and do the same task, thus making
this solution kind of magical, but I can't find a way, this is another
story.
--
Sent from: http://pas2js.38893.n8.nabble.com/
More information about the Pas2js
mailing list