Get ready for a long post
:
To make a button, you need to make a special type of Procedure called a sender. Its basically a procedure which works on a form.
so:
PHP Code:
Procedure ClickTheOKButton(sender: TObject);
Begin
(The name from form).Caption := FrmAth.Caption+'.'; //This adds a 'Period' to the end of the title. Its so if something goes wrong, you can see what, but most of the time its useless.
(The name from form).ModalResult := mrOk; //Tells the script that everything is A-OK and we should carry on.
end;
Now to the main form procedure:
PHP Code:
Ok := TButton.Create(frmDesign);
Ok.Parent := frmDesign;
Ok.Left := 39;
Ok.Top := 86;
Ok.Width := 46;
Ok.Height := 27;
Ok.Caption := 'Ok';
Ok.TabOrder := 9;
OK.OnClick := @ClickTheOKButton; //Ive added this line. this says when the button is clicked, calle the ClickTheOKButton procedure.
And thats a button done.
The only bad thing about it though is that if you were to press the X button on the form to close it down the script would still continue. So here is what i added. A global Variable called ScriptStart:
PHP Code:
Var
ScriptStart: Boolean;
Procedure ClickTheOKButton(sender: TObject);
Begin
(The name from form).Caption := FrmAth.Caption+'.';
(The name from form).ModalResult := mrOk;
ScriptStart := True;
end;
Procedure InitForm;
Begin
//The usual Stuff here
end;
//3 boring procedures here all forms need, which you already have
//mainLoop:
Begin
SafeInitForm;
SafeShowFormModal;
If(ScriptStart = False)then
TerminateScript;
setupsrl;
DeclarePlayers;
WriteName;
end.
Now this means that ScriptStart will only be set to true if that button is clicked. If not, it will be false and hence the script will terminate
Thats all
Good luck scripting!