PDA

View Full Version : Multiform(Dinamically create form and call it from script))



CynicRus
11-13-2012, 05:18 PM
var
DsgnForm:TForm;

TestForm: TForm;
TButton0,CloseButton: TButton;
const
default = 'Comic Sans MS';


procedure CloseMe(Sender: TObject);
begin
TestForm.Free;
end;
procedure YourClickProcedure(Sender: TObject);
begin
TestForm:=TForm.Create(nil);
with TestForm do
begin
Caption:='small test form';
Left:=100;
Top:=100;
Width:=420;
Height:=407;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
CloseButton:=TButton.Create(TestForm);
with TButton0 do
begin
Parent:=TestForm;
Caption:='CloseMe';
Left:=132;
Top:=154;
Width:=75;
Height:=25;
OnClick:=@CloseMe;
enabled:=true;
end;
TestForm.SHOW;
end;


procedure InitForm;
begin
//DsgnForm\\
DsgnForm:=TForm.Create(nil);
with DsgnForm do
begin
Caption:='DsgnForm';
Left:=0;
Top:=0;
Width:=420;
Height:=407;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
//TButton0\\
TButton0:=TButton.Create(DsgnForm);
with TButton0 do
begin
Parent:=DsgnForm;
Caption:='TButton0';
Left:=132;
Top:=154;
Width:=75;
Height:=25;
OnClick:=@YourClickProcedure;
enabled:=true;
end;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;


procedure ShowFormModal;
begin
DsgnForm.ShowModal;
end;


procedure SafeShowFormModal;
var
v: TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;


begin
SafeInitForm;
SafeShowFormModal;
end.

Le Jingle
11-13-2012, 06:43 PM
So, from my test of your snippet above;

The Created form, the 1st Form, allows "second form" so you can present Settings (within dynamic forms) clearly?

Hope I got that right :) Nice work CynicRus!