-3

I have come across a below function in a delphi code. I am quite new to delphi.There are quite a few places in Delphi where this function is called. However I can't seem to find the definition of this function. Could someone please explain what this means.

property OnProcessEvent: TOnProcessEventProc read FOnProcessEvent write FOnProcessEvent; 
Ken White
  • 123,280
  • 14
  • 225
  • 444
liv2hak
  • 14,472
  • 53
  • 157
  • 270
  • Read this, http://stackoverflow.com/questions/21403628/how-can-i-search-for-delphi-documentation and then this http://docwiki.embarcadero.com/RADStudio/en/Properties – David Heffernan Jan 20 '16 at 22:56
  • And this too http://docwiki.embarcadero.com/RADStudio/en/Events – David Heffernan Jan 20 '16 at 23:02
  • You've given no context for the code you've posted. It may or may not be part of the VCL/RTL; it's conceivable that anyone could create a class with that property and type (I can do so in about a half dozen lines of code). If you want information about code, you need to include enough context for it to be answered. We can't see your screen or read your mind to tell where you found the code or what class the property belongs to, so you need to include that information in your question. – Ken White Jan 20 '16 at 23:26
  • You can also use *Search->Find in files* to search the VCL source code (which comes with nearly every version of Delphi) to find definitions as well. Just include subdirectories by checking the box, give it a `*.pas` file filter, and point it to your Delphi\Source folder. – Ken White Jan 21 '16 at 01:10

1 Answers1

1

That declaration is not a function, it is a property, or more specifically an event. In that same class, you will see a data member named FOnProcessEvent of type TOnProcessEventProc. If you look at the declaration of TOnProcessEventProc, you will see that it is an alias for a method pointer of a specific signature, eg:

type
  TOnProcessEventProc = procedure(Sender: TObject; ... other parameters here ...) of object;

That means any non-static class method that matches that signature can be assigned to the OnProcessEvent event. And if the event is declared as published, such a method can even be assigned at design-time instead of in code at run-time.

In the code for the class that declares the event property, all it has to do is call FOnProcessEvent() as if it were a procedure, eg:

if Assigned(FOnProcessEvent) then
  FOnProcessEvent(Self, ... parameter values here ...);

Whatever method is actually assigned to FOnProcessEvent, if any, will be called.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770