text: Q:
  
  How to declare record containing events which use record as parameter
  
  I'm trying to figure out how to declare both a record and a number of object events which use each other. The problem is no matter which way I declare them, I have an "undeclared identifier".
  So with the code below, can I get them to use each other? The events will be used in an object, and the record will be passed and used into the object's constructor.
    TMyEvent = procedure(Sender: TObject; var Rec: TMyRecord) of object;
  
    TMyRecord = record
      OnMyEvent: TMyEvent;
    end;
  
  Is this possible? It needs to work in all versions of Delphi 7 and up.
  
  A:
  
  If you're using a more recent Delphi version, you can declare types within records. Here is how you can reference the record from your event:
  type
    TMyRecord = record
    public type
      TMyEvent = procedure (Sender: TObject; var Rec: TMyRecord) of object;
    public
      OnMyEvent: TMyEvent;
    end;
  
  A:
  
  Unfortunately forward declarations are only allowed for classes but not records, so the only way I know of is to use pointers:
  PMyRecord = ^TMyRecord;
  
  TMyEvent = procedure(Sender: TObject; Rec: PMyRecord) of object;
  
  TMyRecord = record
    OnMyEvent: TMyEvent;
  end;
  
  