Hello all:

I am making something that should be really easy into something really
difficult; 

I have created a composite control, containing an edit box and several
speed buttons.  One of the speed buttons, on the click event, I would
like to substitute a new event for the TNotifyEvent that normally occurs. 

The original code using the default handler looks like this:
------------------
Function GetBtn1Click: TNotifyEvent;
Procedure SetBtn1Click(const E: TNotifyEvent);

property OnBtn1Click: TNotifyEvent read GetBtn1Click write SetBtn1Click;

Function TjmEdit.GetBtn1Click: TNotifyEvent;
Begin
   Result := FBtn1.OnClick;
End;
Function TjmEdit.SetBtn1Click(const E: TNotifyEvent)
Begin
   FBtn1.OnClick := E;
End;
-------------------
This works - when I create a handler to deal with the click it works fine.

Here is what I want, however.  I would like to create this component
such that it will allow me to attach a different event handler
signature.  For example, I want to define my new event as follows:

TjmFileRefBtnPressedEvent = procedure(Sender: TObject; var FileRec:
                           Integer; var FileName: String) of object;

I would like to assign this to the button click instead of the
TNotifyEvent (the compiler absolutely hates this, since the procedure
signature is different.)  

What kind of magic do I need to do to get this to work?  Ideally,
inside my component, some kind of code will act as a moderator
between the original TSpeedButton.OnClick event and the new
TjmFileRefBtnPressedEvent.  If no event handler is assigned, pressing
the button would do nothing.  If I assign a handler, such as 

Procedure WorkWithFileRepository(Sender: TObject; Var Key: Integer; 
                                 Var Fil: String);

then pressing the button would execute this method.

Thank
jamie
















Reply via email to