Results 1 to 7 of 7

Thread: OnItemClick

  1. #1
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default OnItemClick

    SCAR Code:
    var
      frmMain: TForm;
      UserList: TCheckListBox;

    procedure Panel2Clic(Sender: TObject; Index: Integer);
    begin

    end;

    procedure InitForm;
    begin
      frmMain := TForm.Create(nil);
      frmMain.SetBounds({L} 100, {T} 100, {W} 600, {H} 400);

    UserList := TCheckListBox.Create(frmmain);
    UserList.Parent := frmmain;
    UserList.SetBounds(24,40,225,241);
    UserList.OnItemClick := @Panel2Clic;
    end;

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

    procedure ShowFormModal;
    begin
      frmMain.ShowModal;
    end;

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

    begin
      try
        SafeInitForm;
        SafeShowFormModal;
      finally
        frmMain.Free;
      except
        Writeln(ExceptionToString(ExceptionType, ExceptionParam));
      end;
    end.
    Anyone know what's wrong with this?
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  2. #2
    Join Date
    Mar 2009
    Location
    Norway
    Posts
    493
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Arrays can't have a size of 0, can they?

  3. #3
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  4. #4
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    it should be OnClick

    ~shut
    .OnClick for SCAR only bro, I gather he's using Simba.
    It works fine in SCAR with just Sender: TObj and .OnClick, if that's actually any consolation to you, which it probably is not.

    The problem seems to be in this line:
    SCAR Code:
    UserList.OnItemClick := @Panel2Clic;
    If that helps in any way, I'm not sure about what .OnItemClick accepts, haven't use Simba in a while..

    Hope that helps in some shape or form.

  5. #5
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Yea, for some reason Simba only has OnClickItem and OnClickCheck or something like that. I knew what line was the problem, and i had to look it up on the lazarus site to get the arguments. The script wont compile without the correct ones, and this one dies after compiling, so i assume that they're right.
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  6. #6
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    What exactly is the problem? Could you quickly summarize the problem? I didn't get to fully understand the problem.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  7. #7
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Exception: Access violation
    Error: Out Of Range at line 638
    at UserList.OnItemClick := @Panel2Clic;

    EDIT: Wizzup or MastaRaymond?
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


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
  •