SRL Archive - OSR Advanced Scripting Tutorials

Complete Form Tutorial


BobboHobbo

2007-11-14 06:35:53

Form - How to make a form Basic to Advance.

Chapter 1: Creating a basic form.

*Under Construction*

Chapter 1: Creating a basic form.
Starting off, open up scar and go to tools > Form Editor. Now a Grayed dotted box should show up, by the conner of the dotted grayed box make it to the size you want the form to be.On the side of the grayed box you have a menu panel on the top. Example bellow:
Now you can see the Top menu bar has pictures showing what it makes. Example the button button. Click it from the top Menu.


Click that button picture and then click somewhere on the grayed dotted box thing. A button will show up you can move it all around and do what you want with it with sizes names etc. How to change the Caption of the Button? well click on the button and on on the right a box should have a bunch of writing in it.


On here you can do everything you want with the button, if you want to change what shows up on the button click on the Caption Option which is highlighted on the picture above. This controlls what is written on the button. BUT before you change the name of the Caption change the name of the button itself, so you can easily identify it in your script. Where it says Name Button1 on the right panel thing thats where you put the name of the button, change to StartButton.

Now make 2 Edit boxes using:
Then the top one as TopBox and the lower edit box BottomBox.
Should look something like this:
Now Click the Save button located on the top Menu bar. Save it in a spot where you will find.

Now, the coding part. Go to Tools > Load DFM Form. Now find where you saved your form, and when you did that look in your debug box.

frmDesign := CreateForm;
frmDesign.Left := 250;
frmDesign.Top := 114;
frmDesign.Width := 181;
frmDesign.Height := 201;
frmDesign.Caption := 'frmDesign';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := True;
frmDesign.PixelsPerInch := 96;
Button1 := TButton.Create(frmDesign);
Button1.Parent := frmDesign;
Button1.Left := 40;
Button1.Top := 96;
Button1.Width := 75;
Button1.Height := 25;
Button1.Caption := 'Button1';
Button1.TabOrder := 8;
Edit1 := TEdit.Create(frmDesign);
Edit1.Parent := frmDesign;
Edit1.Left := 24;
Edit1.Top := 40;
Edit1.Width := 121;
Edit1.Height := 21;
Edit1.TabOrder := 9;
Edit1.Text := 'Edit1';
Edit2 := TEdit.Create(frmDesign);
Edit2.Parent := frmDesign;
Edit2.Left := 24;
Edit2.Top := 64;
Edit2.Width := 121;
Edit2.Height := 21;
Edit2.TabOrder := 10;
Edit2.Text := 'Edit2';


//Add these objects to variable declarations
var
frmDesign : TForm;
Button1 : TButton;
Edit1 : TEdit;
Edit2 : TEdit;

You will see something like this. Now we need to make it work proper, so put the Vars at the top of the script and put the form stuff in a procedure, ill shoe bellow.


var
frmDesign : TForm;
Button1 : TButton;
Edit1 : TEdit;
Edit2 : TEdit;
procedure FormStuff;
begin
frmDesign := CreateForm;
frmDesign.Left := 250;
frmDesign.Top := 114;
frmDesign.Width := 181;
frmDesign.Height := 201;
frmDesign.Caption := 'frmDesign';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := True;
frmDesign.PixelsPerInch := 96;
Button1 := TButton.Create(frmDesign);
Button1.Parent := frmDesign;
Button1.Left := 40;
Button1.Top := 96;
Button1.Width := 75;
Button1.Height := 25;
Button1.Caption := 'Button1';
Button1.TabOrder := 8;
Edit1 := TEdit.Create(frmDesign);
Edit1.Parent := frmDesign;
Edit1.Left := 24;
Edit1.Top := 40;
Edit1.Width := 121;
Edit1.Height := 21;
Edit1.TabOrder := 9;
Edit1.Text := 'Edit1';
Edit2 := TEdit.Create(frmDesign);
Edit2.Parent := frmDesign;
Edit2.Left := 24;
Edit2.Top := 64;
Edit2.Width := 121;
Edit2.Height := 21;
Edit2.TabOrder := 10;
Edit2.Text := 'Edit2';
end;

Now we need to add the main parts of a form:

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


procedure ShowformModal;
begin
frmDesign.ShowModal;
end;


procedure SafeShowModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowformModal', v);
end;
You need all these 3 procedures to make a form to show up THEY are verry important!! Like: (look down into the scar code)

program Form;
var
frmDesign : TForm;
Button1 : TButton;
Edit1 : TEdit;
Edit2 : TEdit;
procedure FormStuff;
begin
frmDesign := CreateForm;
frmDesign.Left := 250;
frmDesign.Top := 114;
frmDesign.Width := 181;
frmDesign.Height := 201;
frmDesign.Caption := 'frmDesign';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := True;
frmDesign.PixelsPerInch := 96;
Button1 := TButton.Create(frmDesign);
Button1.Parent := frmDesign;
Button1.Left := 40;
Button1.Top := 96;
Button1.Width := 75;
Button1.Height := 25;
Button1.Caption := 'Button1';
Button1.TabOrder := 8;
Edit1 := TEdit.Create(frmDesign);
Edit1.Parent := frmDesign;
Edit1.Left := 24;
Edit1.Top := 40;
Edit1.Width := 121;
Edit1.Height := 21;
Edit1.TabOrder := 9;
Edit1.Text := 'Edit1';
Edit2 := TEdit.Create(frmDesign);
Edit2.Parent := frmDesign;
Edit2.Left := 24;
Edit2.Top := 64;
Edit2.Width := 121;
Edit2.Height := 21;
Edit2.TabOrder := 10;
Edit2.Text := 'Edit2';
end;

procedure ShowForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('FormStuff', v);
end;
procedure ShowformModal;
begin
frmDesign.ShowModal;
end;
procedure SafeShowModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowformModal', v);
end;
Begin
ShowForm;
SafeShowModal;
end.


BobboHobbo

2007-11-14 07:25:45

Reseerved* not good at making tuts :(

Soo tired ill do more tomoz.

HyperSecret

2007-11-16 01:31:08

leaving the srl-community, but writing a tut?…lol cant make up the mind huh? looks like a good tut, will definitely will be making a form for my next script

Santa_Clause

2007-11-16 03:39:59

You better add tabs :p

BobboHobbo

2007-11-16 06:46:32

From: HyperSecret
leaving the srl-community, but writing a tut?…lol cant make up the mind huh? looks like a good tut, will definitely will be making a form for my next script


I wrote before i left but back ina day how weird :D

From: Santa_Clause
You better add tabs :p


I sure will!

Sir R. M8gic1an

2008-01-06 16:47:18

going good, but i want more :p how do i add many choices to a list? tabs? sned to back and send to front, group boxes, scroll bars?!

~RM :)

tom99

2009-12-07 07:00:59

Error:
[Runtime Error] : Exception: Cannot make a visible window modal in line 64 in script
Failed when compiling

marpis

2009-12-10 04:29:33

Plxx thabz!!1 :(

putonajonny

2012-03-09 18:52:12

From: Sir R. M8gic1an
going good, but i want more :p how do i add many choices to a list? tabs? sned to back and send to front, group boxes, scroll bars?!

~RM :)


I know this is from 2008, but yes, how do you do scroll bars?

Daniel

2012-03-09 19:58:10

TScrollBar ;)

Chry

2012-05-29 09:36:41

Seems not bad.