Results 1 to 10 of 10

Thread: Ultimate form tutorial

  1. #1
    Join Date
    May 2007
    Location
    baltimore, md
    Posts
    836
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default Ultimate form tutorial

    Hey this is my complete form tutorial. I am going to compile all my knowledge about forms together to make one massive tutorial. I will break it down into sections. Since i have school i will not release this all at once but when i get the time.

    Section 1: Basics
    Basic form setup
    Form editor

    Done.

    Section 2: Buttons
    Adding a button
    Changing button text
    Button events


    Section 3: Labels
    Adding a label
    Changing label


    Section 4: Edit Boxes
    Adding an edit box
    Getting text from an edit box
    Password character
    Edit box events


    Section 5: Combo boxes
    Adding a combo box
    Adding combo box items
    Getting combo box text
    Combo box events


    Section 6: Check boxes/Radio buttons
    Adding check boxes/radio buttons
    Check box/radio button checked?
    Events


    Section 7: Changing colors
    Changing background color
    Changing text color


    Section 8: Misc form objects
    Bevels
    Group boxes
    Images
    Progress bar


    Section 9: Multiplayers
    Already made a tut on this



    Basics
    Basic form setup
    The basic way to set up a form is described in the scar manual. I will post here and explain this further though.
    SCAR Code:
    program New;
    var
      frmDesign : TForm;
     
    procedure InitForm;
    begin
      frmDesign := CreateForm;
      frmDesign.Left := 259;
      frmDesign.Top := 132;
      frmDesign.Width := 354;
      frmDesign.Height := 254;
      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 := False;
      frmDesign.PixelsPerInch := 96;
    end;

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

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

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

    begin
      SafeInitForm;
      SafeShowFormModal;
    end.
    This is the base of every form created through the form editor. The first thing done is the forms variables are created.
    SCAR Code:
    program New;
    var
      frmDesign : TForm;
     
    procedure InitForm;
    begin
      frmDesign := CreateForm;
      frmDesign.Left := 259;
      frmDesign.Top := 132;
      frmDesign.Width := 354;
      frmDesign.Height := 254;
      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;
    end;
    If you used a form editor to get the form it will basically give you this code.
    This is just the variable frmDesign declared as a Tform. Then it is created through the procedure initform. What you made the form look like in the form editor will all be labeled here.
    One thing you must remember though is to change
    SCAR Code:
    frmDesign.Visible := True;
    To
    SCAR Code:
    frmDesign.Visible := False;
    If you do not you will get an error.
    The next step is to make the form thread safe and make sure the script shows it. That is where these procedures come in.
    SCAR Code:
    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowFormModal;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;
    The reason is has to be thread safe is because there is a good chance scar will crash. Most of scars functions already are thread safe but not all of them are.
    The next step is to just call the thread safe procedures in the main loop.
    SCAR Code:
    begin
      SafeInitForm;
      SafeShowFormModal;
    end.
    After that you will have a script that looks like this.
    SCAR Code:
    program New;
    var
      frmDesign : TForm;
     
    procedure InitForm;
    begin
      frmDesign := CreateForm;
      frmDesign.Left := 259;
      frmDesign.Top := 132;
      frmDesign.Width := 354;
      frmDesign.Height := 254;
      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 := False;
      frmDesign.PixelsPerInch := 96;
    end;

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

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

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

    begin
      SafeInitForm;
      SafeShowFormModal;
    end.
    They press play and you will see a blank form.

    Form editor
    The form editor is an easy to use built in feature of scar. It makes form making extremely easy when it comes to designing the form. I will explain the basic components of the form editor in this section.
    You can open the form editor by going to Tools->Form editor


    This is what you see when you click on the form editor.

    The form template is where you drag your items to. The objects are what you are putting on the form. The object inspector is how you change the properties of objects. I will go into more detail with each tutorial that comes up.

    More to come when i get the time!

  2. #2
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow, i imagine this will be a VERY good tutorial when you get around to adding all of those other things.

    [offtopic, but still having to do with forms] since you are incredibly good at forms, do you think you could take a look at my thread? http://www.villavu.com/forum/showthr...100#post212100
    [/offtopic, but still having to do with forms]

  3. #3
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Cool! GJ jhildy!


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  4. #4
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    i may add forms once you get this tut done

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  5. #5
    Join Date
    May 2007
    Location
    NSW, Australia
    Posts
    2,823
    Mentioned
    3 Post(s)
    Quoted
    25 Post(s)

    Default

    Very nice for just one section, cant wait to see it when its all done.

    GJ

  6. #6
    Join Date
    May 2007
    Location
    Netherlands, Amersfoort
    Posts
    2,701
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Gs keep it up

    (good start )

  7. #7
    Join Date
    May 2007
    Location
    in a pineapple under the sea
    Posts
    1,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    even though this is a gravedig i feel this tutorial is very important (so its not really a gravedig)

    and i would love to say Jhildy did a wonderful job
    [SIZE="4"][CENTER][URL="http://www.youtube.com/watch?v=5YsGJz3j4os"]LOL u mad bro?[/URL][/CENTER][/SIZE]

  8. #8
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    wow thanks for the GRAVEDIG lol i did not even know this tut EXISTED thanks though wished bobbo and jhidly finished on the tuts but thanks ill read it

  9. #9
    Join Date
    Jul 2007
    Posts
    1,431
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well, I can handle simple forms pretty well, but this doesn't work =/, is it about windows vista or my script or scar 3.14, List is name of students in my class, "on loll", means "is stupid"

    SCAR Code:
    program New;

    var
      frmDesign : TForm;
      Label1 : TLabel;
      Button1 : TButton;
      list : TStringList;
      i : integer;
     
    procedure buttonclick(sender: TObject);
    begin
      Label1.Caption := List[i]+' on loll!';
      i := i + 1;
    end;

    procedure InitForm;
    begin
    frmDesign := CreateForm;
    frmDesign.Left := 250;
    frmDesign.Top := 114;
    frmDesign.Width := 370;
    frmDesign.Height := 186;
    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 := False;
    frmDesign.PixelsPerInch := 96;
    Label1 := TLabel.Create(frmDesign);
    Label1.Parent := frmDesign;
    Label1.Left := 16;
    Label1.Top := 80;
    Label1.Width := 3;
    Label1.Height := 13;
    Button1 := TButton.Create(frmDesign);
    Button1.Parent := frmDesign;
    Button1.Left := 16;
    Button1.Top := 24;
    Button1.Width := 321;
    Button1.Height := 41;
    Button1.Caption := 'Button1';
    Button1.TabOrder := 8;
    Button1.OnClick:= @buttonclick;
    end;
     
    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

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

    begin
      SetLength(List, 7);
      List[0] := 'Romet';
      List[1] := 'Tõnis';
      List[2] := 'Allen';
      List[3] := 'Tiit';
      List[4] := 'Kati';
      List[5] := 'Mihkel';
      List[6] := 'Sander';
     
      SafeInitForm;
      writeln('1');
      SafeShowFormModal;
      writeln('2');
    end.

    Edit: It doesn't writeln anything to debug, and if Visible is wrong, then I'd have to admit I tryed both ^^
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

  10. #10
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    can you please finish this tut?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. THE big form tutorial ~ by MK
    By MasterKill in forum OSR Advanced Scripting Tutorials
    Replies: 125
    Last Post: 08-04-2013, 07:32 PM
  2. The Form Tutorial
    By Dan Cardin in forum OSR Advanced Scripting Tutorials
    Replies: 28
    Last Post: 03-03-2011, 04:42 AM
  3. Ultimate Noob Tutorial!
    By Bego in forum Outdated Tutorials
    Replies: 165
    Last Post: 09-13-2009, 05:37 AM
  4. [TUT] Ultimate Form Guide [TUT]
    By ronny.m.p in forum OSR Advanced Scripting Tutorials
    Replies: 34
    Last Post: 08-25-2008, 01:38 AM
  5. Please requesting the ultimate tutorial runner
    By RudeBoiAlex in forum RS3 Outdated / Broken Scripts
    Replies: 3
    Last Post: 03-09-2007, 01:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •