PDA

View Full Version : Need help with reflection forms.



kakadudl
03-20-2016, 04:25 PM
Hello!

I've been trying to make a form for my script but I can't find a way to do it with reflection. I was told to use ezForm but I want to make one from scratch.
So the thing is...form makes in simba returns code which can be only used on PascalScript interpreter but I need it on lape for use with lape reflection.

This is the code of simba form editor:


var
MainForm:TForm;
const
default = 'Comic Sans MS';


procedure YourClickProcedure(Sender: TObject);
begin
ShowMessage('click');
end;

procedure InitForm;
begin
//MainForm\\
MainForm:=TForm.Create(nil);
with MainForm do
begin
Caption:='Script setup';
Left:=269;
Top:=432;
Width:=600;
Height:=240;
Font.Name:=default;
Font.Color:=clDefault;
Font.Size:=0;
end;
end;

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

procedure ShowFormModal;
begin
MainForm.ShowModal;
end;

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

begin
SafeInitForm;
SafeShowFormModal;
end.


What I modified for lape:

var
MainForm : TForm;

const
default = 'Comic Sans MS';

procedure YourClickProcedure(Sender: TObject);
begin
ShowMessage('click');
end;

procedure InitForm;
var
Font : TFont;
begin
//DsgnForm\\
MainForm.Init(nil);
Font.Init;
Font.SetDefault;
with MainForm do
begin
setCaption('Script setup');
setLeft(174);
setTop(307);
setWidth(320);
setHeight(240);
end;
end;

procedure ShowFormModal;
begin
MainForm.ShowModal;
end;

begin
InitForm;
ShowFormModal;
end.

When I try to run it it gives me simba error:

Program exception!
Stacktrace:

Exception class: EThread
Message: CheckSynchronize called from non-main thread "$1A74"
$004596E1
$0050A33D
$0041F803
$0083411F
$0075DEC2
$00600BC3
$004590F8
Simba Version: 1100


I'm guessing I don't load it correctly and I can't find a good example which would show me how to do it.

Thanks for your help in advance :)

Obscurity
03-20-2016, 06:15 PM
Again, on my phone (will try when I get home), but try:
initForm;
sync(showFormModal);
end;

kakadudl
03-20-2016, 07:21 PM
Again, on my phone (will try when I get home), but try:
initForm;
sync(showFormModal);
end;

Tried that it only gives me cannot invoke identifier error :)

Obscurity
03-20-2016, 07:42 PM
var
MainForm:TForm;

procedure YourClickProcedure(Sender: TObject);
begin
ShowMessage('click');
end;

procedure InitForm;
begin
//MainForm\\
MainForm.Init(nil);
with MainForm do
begin
SetCaption('Script setup');
SetLeft(269);
SetTop(432);
SetWidth(600);
SetHeight(240);
//~ ...
end;
end;

procedure ShowForm; native;
begin
MainForm.showModal();
end;

begin
InitForm;
Sync(ShowForm);
end.

Still, I'd suggest eZForm. :P.

kakadudl
03-20-2016, 07:50 PM
var
MainForm:TForm;

procedure YourClickProcedure(Sender: TObject);
begin
ShowMessage('click');
end;

procedure InitForm;
begin
//MainForm\\
MainForm.Init(nil);
with MainForm do
begin
SetCaption('Script setup');
SetLeft(269);
SetTop(432);
SetWidth(600);
SetHeight(240);
//~ ...
end;
end;

procedure ShowForm; native;
begin
MainForm.showModal();
end;

begin
InitForm;
Sync(ShowForm);
end.

Still, I'd suggest eZForm. :P.

Thank you very much :)

Obscurity
03-20-2016, 07:54 PM
Unfortunately, a lot of the old tutorials (which I'm assuming you were using) no longer apply and there's really no docs on newer material. If my date-plans tonight fall through, maybe I'll write a newer form tutorial (without eZF). :).

For now, if you want an idea of adding components:
https://github.com/ObscuritySRL/eZForm/blob/master/ezForm.simba#L149-L450

kakadudl
03-20-2016, 08:22 PM
I was looking at ineedbot +'s AIO fisher because I couldn't find anything else but it's kinda messed up with all other functions. If you make a tutorial I'll surely read it. Thanks for all the useful info tho