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.
SCAR Code:
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.
SCAR Code:
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:
SCAR Code:
procedure ShowForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('FormStuff', v);
end;
SCAR Code:
procedure ShowformModal;
begin
frmDesign.ShowModal;
end;
SCAR Code:
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)
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.