Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6215113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:59:47+00:00 2026-05-24T06:59:47+00:00

Say I have a Button1.OnClick event linked to Button1Click procedure. I also have Button2.OnClick

  • 0

Say I have a Button1.OnClick event linked to Button1Click procedure. I also have Button2.OnClick linked to some other procedure. How do I check that both events are linked to different or same procedure from runtime?

I tried to test if:

  • Button1.OnClick = Button2.OnClick, but that gave me an error (Not enough actual parameters)
  • @(Button1.OnClick) = @(Button2.OnClick), error again (Not enough actual parameters)

How do I test it properly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:59:47+00:00Added an answer on May 24, 2026 at 6:59 am

    A method reference can be broken down in to two parts, the pointer to the object and the pointer to the method itself. There is a convenient record type defined in the System unit called TMethod that allows us to do that break down.

    With that knowledge, we can write something like this:

    function SameMethod(AMethod1, AMethod2: TNotifyEvent): boolean;
    begin
      result := (TMethod(AMethod1).Code = TMethod(AMethod2).Code) 
                and (TMethod(AMethod1).Data = TMethod(AMethod2).Data);   
    end;
    

    Hope this helps. 🙂

    Edit: Just to lay out in a better format the problem I am trying to solve here (as alluded to in the comments).

    If you have two forms, both instantiated from the same base class:

    Form1 := TMyForm.Create(nil);
    Form2 := TMyForm.Create(nil);
    

    and you assign the same method from those forms to the two buttons:

    Button1.OnClick := Form1.ButtonClick;
    Button2.OnClick := Form2.ButtonClick;
    

    And compare the two OnClick properties, you will find that the Code is the same, but the Data is different. That is because it’s the same method, but on two different instantiations of the class…

    Now, if you had two methods on the same object:

    Form1 := TMyForm.Create(nil);
    
    Button1.OnClick := Form1.ButtonClick1;
    Button2.OnClick := Form1.ButtonClick2;
    

    Then their Data will be the same, but their Code will be different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am coming from asp.net and in asp.net you have the onclick event that
Lets say I have one row with three columns - some buttons on left
Say I have an button with a touchEnd event listener. If I touch the
I know that ASP.NET controls such as the button have the postback event model.
Lets say that I have two different types of RelativeLayouts. That is to say
Let's say I have an embed code with a script that adds events to
Say I have a User Control in ASP.NET that contains a button: public class
Say I have textboxes, dropdownlists and submit buttons. They are all inline-elements. Which means
For simplicity lets say I have two flex mxml pages. form.mxml button.mxml If the
I have a few text boxes and buttons on my form. Lets say txtBox1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.