Results 1 to 9 of 9

Thread: Another Form Question -

  1. #1
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Another Form Question -

    Hi all, again. I have another form question, hopefully I can get it answered.

    How would I make it to where if something in ListBox1 is selected, it will make the script do something? Such as

    User selects his/her options.. (This is in ListBox1):
    Take P2P Path
    Take F2P path

    Then they hits a button like 'Save' or 'Ok'. Then the script would act accordingly?

    Thanks in advance. By the way, if it could be shown in an example code please.

  2. #2
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    put this in InitForm (The procedure where you declare all the form variables):
    SCAR Code:
    BUTTON_NAME.OmClick := @ButtonClicked;

    And put this ABOVE InitForm:
    SCAR Code:
    procedure ButtonClicked(Sender : TObject);
    begin
      case Sender of
        BUTTON_NAME: begin
                                WriteLn('Button Clicked! :)');
                              end;
      end;
    end;
    Last edited by Zyt3x; 01-21-2010 at 11:53 AM.

  3. #3
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks Zyt3x, but that's not what I'm looking for.. I want something like this..



    As you can see, there are two options in the ListBox1, I want whenever the user/botter has selected one of them and has hit 'Set Options' button, they will be applied to the script. I guess I'm looking for something like..

    Code:
     if Listbox1.Item1 = selected then
      // da da da da

  4. #4
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    SCAR Code:
    var
      frmDesign : TForm;
      ListBox1 : TListBox;
      Button1 : TButton;
     
    procedure ListClicked(Sender : TObject);
    begin
      WriteLn(IntToStr(ListBox1.ItemIndex));
    end;
     
    procedure initform;
    begin
      frmDesign := CreateForm;
      frmDesign.Left := 250;
      frmDesign.Top := 114;
      frmDesign.BorderStyle := bsSingle;
      frmDesign.Caption := 'frmDesign';
      frmDesign.ClientHeight := 203;
      frmDesign.ClientWidth := 163;
      frmDesign.Color := clBtnFace;
      frmDesign.Font.Color := clWindowText;
      frmDesign.Font.Height := -11;
      frmDesign.Font.Name := 'MS Sans Serif';
      frmDesign.PixelsPerInch := 96;
      ListBox1 := TListBox.Create(frmDesign);
      ListBox1.Parent := frmDesign;
      ListBox1.Left := 8;
      ListBox1.Top := 8;
      ListBox1.Width := 104;
      ListBox1.Height := 176;
      ListBox1.ItemHeight := 13;
      ListBox1.OnClick := @ListClicked;
      ListBox1.Items.Add('sel1');
      ListBox1.Items.Add('sel2');
      ListBox1.Items.Add('sel3');
      ListBox1.Items.Add('sel4');
      ListBox1.Items.Add('sel5');
      ListBox1.TabOrder := 8;
      Button1 := TButton.Create(frmDesign);
      Button1.Parent := frmDesign;
      Button1.Left := 120;
      Button1.Top := 8;
      Button1.Width := 25;
      Button1.Height := 176;
      Button1.ModalResult := 1;
      Button1.TabOrder := 9;
    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.
    You see the ListBox1.ItemIndex? That tells the script what index the list is at, so in your case F2P Path = index 0 and P2P Path = index 1

    E:
    SCAR Code:
    ListBox1.OnClick := @ListClicked;
    Is important! In the procedure ListClicked; you'll have to put everything for loading the stuff you want to load and so on

    E2: It is also possible to make the script so that it loads the stuff when a button is clicked

    Good luck
    Last edited by Zyt3x; 01-21-2010 at 12:02 PM.

  5. #5
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thank you VERY much, Zyt3x. That is what I was looking for. Really appreciate the help!

  6. #6
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Risk View Post
    Thank you VERY much, Zyt3x. That is what I was looking for. Really appreciate the help!
    No problem
    Glad to help you, and ask again if there is something else you're wondering about

  7. #7
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks for the offer! I'll take you up on that with this new question:

    Would it be possible to make a button in a form open your main browser and go to a website? (I.E. the script's thread). I read the Scripting Regulation thread and from what I understand this type of linking is okay, since it does offer some use to the user/botter. If so, how would I do it?

  8. #8
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    openwebpage('wat.com');



    just put it into your buttonclick sender
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  9. #9
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks a lot, Awkwardsaw! Appreciate the help.

    Quote Originally Posted by Awkwardsaw View Post
    openwebpage('wat.com');



    just put it into your buttonclick sender

Thread Information

Users Browsing this Thread

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

Posting Permissions

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