SRL Archive - Help

forms in simba


g0tp0t

2010-09-20 14:05:40

i use createform but it isn't recognized in simba, i haven't found anything in the forums that shows other people successfully using forms in simba. is it possible?

the reason i want a form is so i can draw on it, i cant seem to get the debug windows canvas so i cant draw in there, =\

Wizzup?

2010-09-20 14:19:06

TForm.Create? Remember that all the form stuff should be in ThreadSafeCalls.

BraK

2010-09-20 14:46:46

So that's why I've been failing to get my player form off the ground.:duh:

We need some Updated Form Tut's for Simba

~Brak

Shuttleu

2010-09-20 14:51:03

also if you include srl then you can use CreateForm

~shut

Dgby714

2010-09-20 14:53:44

From: Wizzup?
TForm.Create? Remember that all the form stuff should be in ThreadSafeCalls.


After looking in simba wouldn't it be "TForm.Create(nil);"? or should something else go as the parameter?

Wizzup?

2010-09-20 14:56:39

From: Dgby714
After looking in simba wouldn't it be "TForm.Create(nil);"? or should something else go as the parameter?


Nil would do, yeah.

g0tp0t

2010-09-27 12:14:38

iv been trying to figure simba out, and havnt found any tutorials for drawing or using forms. It doesnt look like ther are manyt tuts at all. I would really like to see a thread with many differences between scar and simba.

Ohh, i hink i found a bug,


program new;
var form : Tform;
begin
form := tform.create(nil);
form.show;
end.

Result is the border of the form appears but the form itself is transparent, and simba crashes.

EDIT: stupid stupid stupid, haha. didnt use threadsafecall.

Edit2:

program new;
var
form : tform;
dx1,dx2,dy1,dy2,cr,t,h,k:integer;
v : TVariantArray;

procedure paint(sender : TObject);
begin
t := t+1;
dx1 := round(cr*cos(t)+h)
dy1 := round(cr*sin(t)+k)
dx2 := round(cr*cos(t)-h)
dy2 := round(cr*sin(t)-k)
form.CANVAS.Ellipse(dx1-cr,dy1-cr,dx2+cr,dy2+cr)
end;

procedure show;
begin
cr := 2;
h := 250;
k := 250;
form := tform.Create(nil);
form.width := 500;
form.height := 500;
form.show;
form.ONPAINT := @paint;
end;

begin
ThreadSafeCall('show', v);
end.

output :
Error: Exception: Invalid type cast at line 30

Am i doing something wrong?

Wizzup?

2010-09-27 17:42:14

I fixed the tags for you. Use
 and not < simba >. :)

Mr. Doctor

2010-09-27 17:50:14


program new;
var
form : tform;
dx1,dx2,dy1,dy2,cr,t,h,k:integer;
v : TVariantArray;

procedure paint(sender : TObject);
begin
t := t+1;
dx1 := round(cr*cos(t)+h)
dy1 := round(cr*sin(t)+k)
dx2 := round(cr*cos(t)-h)
dy2 := round(cr*sin(t)-k)
form.CANVAS.Ellipse(dx1-cr,dy1-cr,dx2+cr,dy2+cr)
end;

procedure InItForm;
begin
cr := 2;
h := 250;
k := 250;
form := tform.Create(nil);
form.width := 500;
form.height := 500;
form.show;
form.ONPAINT := @paint;
end;

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


procedure ShowFormModal;
begin
form.ShowModal;
end;

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

begin
SafeInitForm;
SafeShowFormModal;
ThreadSafeCall('show', v);
end.

http://villavu.com/forum/showthread.php?t=12000

Wizzup?

2010-09-27 17:51:55

You should really use ShowModal (as Mr Doctor did) because that way your Form stuff will keep running in the main thread; until the form is closed. If you use just .Show; the method will return immediately and all events (including onPaint) will be called on the script thread. (AFAIK anyway, I really hate forms, did I mention this before? ;) )

g0tp0t

2010-09-28 13:15:02

sweet, the forms seem overcomplicated. lol

ty for formmodal and the tag change =]. is the source openly available? im wondering because i would like to see the functions and form stuff.

I really wish there was a getdubugcanvas like ther is in scar. painting on canvas is easier. =\

Wizzup?

2010-09-29 19:11:22

From: g0tp0t
sweet, the forms seem overcomplicated. lol

ty for formmodal and the tag change =]. is the source openly available? im wondering because i would like to see the functions and form stuff.

I really wish there was a getdubugcanvas like ther is in scar. painting on canvas is easier. =\


The source is openly available. http://wizzup.org/simba/article/3

g0tp0t

2010-09-30 07:53:22

ok, i went but i cant find a way to see the source code, this is written in delphi or pascal right? how was it compiled

Wizzup?

2010-09-30 08:37:59

From: g0tp0t
ok, i went but i cant find a way to see the source code, this is written in delphi or pascal right? how was it compiled


http://villavu.com/forum/showthread.php?t=58000 :)

g0tp0t

2010-09-30 09:11:01

can the code be seen without lazarus and fpc?

Wizzup?

2010-09-30 09:15:03

From: g0tp0t
can the code be seen without lazarus and fpc?


You can view all .pas files in pretty much every text editor, including notepad.

g0tp0t

2010-09-30 13:32:40

how do i view pas files, i saw the git and clicked and then it wanted to download a file but not a pas

Wizzup?

2010-09-30 13:52:55

You can also view the raw version on the site. And if you download the source you can just open it in notepad. The .pas files too.

g0tp0t

2010-09-30 14:42:17

k, ill try that, havnt seen the .pas files, only snapshots.