SRL Archive - OSR Help

Questions about Forms


Abu

2012-06-12 19:29:41

So I have a few questions about forms that I couldn't find in any tutorials.


First of all, how do I add pictures to a form and which file types are accepted?

How do I use the information given in the form and integrate it into my script?


Currently looks like:



P.S - I will be improving layout don't worry

Brandon

2012-06-12 19:41:54


var
Username, Password: String;
begin
Username:= Form1.TextBox.Text; //<--- or whatever the class members are.
end;

Abu

2012-06-13 13:36:54

Another problem.

How do I actually get a button such as 'Start Script' to close the Form, save the details and carry on? (It's a TButton)

Currently when I press the button there is no response.

putonajonny

2012-06-13 13:55:47

From: abu_jwka
Another problem.

How do I actually get a button such as 'Start Script' to close the Form, save the details and carry on? (It's a TButton)

Currently when I press the button there is no response.


This is how I do it:
On initiating the button do:
Buttons[0].OnClick := @ButtonClick;  //Replace Buttons[0] with the name of your button, I actually do it with a for i := 0 to high(Buttons) do... etc. but this was the easiest way to show you
Buttons[1].OnClick := @ButtonClick;

Then you need:

Procedure ButtonClick(Sender: TObject);
begin
Case Sender of
Buttons[0] : begin
Players[CPlayer].Active := False;
YourFormName.ModalResult:= mrOk;//This closes it
end;
Buttons[1] : begin
Players[CPlayer].Active := True;
//Ive taken it out but here you need to save the info inputted in the form
YourFormName.ModalResult:= mrOk;
end;

end;
end;

Abu

2012-06-13 14:42:24

So the OnClick procedure would look like this?

Procedure ButtonClick(Sender: TObject);
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := TForm1_1.Form1_1.InTheUser.Text;
Pass := TForm1_1.Form1_1.InThePass.Text;
Pin := TForm1_1.Form1_1.InThePin.Text;
Strings[0] := TForm1_1.Form1_1.OreSelected.Text;
Strings[1] := TForm1_1.Form1_1.MethodChosen.Text;
Strings[2] := TForm1_1.Form1_1.PickSupport.Text;
Active := True;
end;

frmDesign.ModalResult:= mrOk;
End;

And after doing the above I could then refer to Players[CurrentPlayer].Variable anywhere in the script and it would use the values used in form and called in this procedure?

EDIT: Never mind the above does work after using ToStr()

putonajonny

2012-06-13 18:10:39

Yeah, you might want to do some validation of the options before you close it :) but essentially yes :)

Abu

2012-06-14 16:34:20

Yeh thanks working like a charm now :)

Just one more question. Anyway I can colour the form? I try TPaintBox but get nothing.


EDIT: Never mind got it working.

Looks like this now:


putonajonny

2012-06-14 17:35:30

From: abu_jwka
Yeh thanks working like a charm now :)

Just one more question. Anyway I can colour the form? I try TPaintBox but get nothing.


EDIT: Never mind got it working.

Looks like this now:



That looks really cool! Great job!

Master BAW

2012-06-17 08:31:55

wow, awesome! I want this too! is there a tutorial on forms?

putonajonny

2012-06-17 09:37:28

From: MasterCrimez
wow, awesome! I want this too! is there a tutorial on forms?


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