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 4242330
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:25:39+00:00 2026-05-21T03:25:39+00:00

type TMyClass = class type PMyClass = ^TMyClass; TMyEvent = procedure(Sender: PmyClass) of object;

  • 0
type 
  TMyClass = class
  type
    PMyClass = ^TMyClass;
    TMyEvent = procedure(Sender: PmyClass) of object;
  public
    FTest: TMyEvent;
    procedure Test;
  end;

procedure TMyClass.Test;
begin
  FTest(@Self); //error!
end;

How do I do it?

  • 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-21T03:25:40+00:00Added an answer on May 21, 2026 at 3:25 am

    What in the world are you trying to do? Of course you cannot call FTest since you haven’t assigned any TMyEvent to it yet! And are PMyClass and TMyEvent really supposed to be parts of TMyClass?

    At least this works perfectly:

    type
      PMyClass = ^TMyClass;
      TMyClass = class;
    
      TMyEvent = procedure(Sender: PMyClass) of object;
    
      TMyClass = class
      private
        FEvent: TMyEvent;
        FSomeValue: string;
      public
        property OnSomething: TMyEvent read FEvent write FEvent;
        property SomeValue: string read FSomeValue write FSomeValue;
        procedure Test;
      end;
    
      TSomeOtherClass = class
      public
        class procedure MyEvent(Sender: PMyClass);
      end;
    
    ...
    
    procedure TForm6.FormCreate(Sender: TObject);
    var
      o: TMyClass;
    begin
    
      o := TMyClass.Create;
      o.SomeValue := 'This is a test.';
      o.OnSomething := TSomeOtherClass.MyEvent;
    
      o.Test;
    end;
    
    { TMyClass }
    
    procedure TMyClass.Test;
    begin
      FEvent(@Self);
    end;
    
    { TSomeOtherClass }
    
    class procedure TSomeOtherClass.MyEvent(Sender: PMyClass);
    begin
      ShowMessage(TMyClass(Sender^).SomeValue);
    end;
    

    Of course, you can also have the TMyEvent in the same object:

    type
      TMyClass = class
      private type
        PMyClass = ^TMyClass;
        TMyEvent = procedure(Sender: PMyClass) of object;
      private
        FEvent: TMyEvent;
        FSomeValue: string;
      public
        procedure TheEventHandler(Sender: PMyClass);
        property OnSomething: TMyEvent read FEvent write FEvent;
        property SomeValue: string read FSomeValue write FSomeValue;
        procedure Test;
      end;
    
    ...
    
    procedure TForm6.FormCreate(Sender: TObject);
    var
      o: TMyClass;
    begin
    
      o := TMyClass.Create;
      o.SomeValue := 'This is a test.';
      o.OnSomething := o.TheEventHandler;
    
      o.Test;
    end;
    
    { TMyClass }
    
    procedure TMyClass.Test;
    begin
      FEvent(@Self);
    end;
    
    procedure TMyClass.TheEventHandler(Sender: PMyClass);
    begin
      ShowMessage(TMyClass(Sender^).SomeValue);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000 What is Kernel protection error?
The Type class has a method IsAssignableFrom() that almost works. Unfortunately it only returns
Exception Type: TypeError at /robots.txt Exception Value: 'str' object is not callable What gives?
With RttiContext.FindType('Classes.TStringList') I get RttiType of TStringList with no problem. But with RttiContext.FindType('MyUnit.TMyClass') I
Type hinting helps the compiler to assume the type of the variable, but, as
What type of variable that can contain 1,000,000,000(a decimal number) takes the most memory
I type the words How do and it pops up a list, and returns
I have a set of classes ( MyClass1, MyClass2, MyClass3 ) that implement an
Is there anything wrong with using an implicit operator like the following: //linqpad c#
$skin_type = green; $category_id = get_cat_ID( single_cat_title(, false)); if($category_id == 218){ $skin_type = blue;

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.