Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The complete project answer is good. But this is an alternate answer showing how to do what you want, in a form you already have.</p> <p>Go into your form, and go to the interface section, in the types area, outside your form's class definition and add a type:</p> <pre><code> interface type TMyEvent = procedure(Sender:TObject;Param1,Param2,Param3:Integer) of object; TMyForm = class(TForm) .... </code></pre> <p>It is traditional, but not required, that the first item in your event be the object sending it, but to use base class TObject instead of your form's actual class type.<br> The other parameters above are not required at all, but are showing you how you would declare your own additional data. if you don't need them, then just use Sender:TObject. And in that case, you don't have to define TMyEvent at all, just use the TNotifyEvent type.</p> <p>Now declare a field that uses that type, in your form:</p> <pre><code>TMyForm = class(TForm) private FMyEvent : TMyEvent; ... </code></pre> <p>Now declare a property that accesses that field, in your form's properties section:</p> <pre><code> // this goes inside the class definition just before the final closing end property MyEvent:TMyEvent read FMyEvent write FMyEvent </code></pre> <p>Now go to where you want that event to 'fire' (get called if it is set) and write this:</p> <pre><code>// this goes inside a procedure or function, where you need to "fire" the event. procedure TMyForm.DoSomething; begin ... if Assigned(FMyEvent) then FMyEvent(Self,Param1,Param2,Param3); end; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload