EventSinkRegEvnt
f90VB Modules
f90VBDefs, f90VBAutomation
Summary
Registers a Fortran function as the function to be executed when the event sink object receives an event from the Automation object to which the sink is connected.
Syntax
| subroutine EventSinkRegEvnt | (EventSink, EventName, PEventHndlr, iRet) |
| integer(POINTER_KIND),intent(in):: | EventSink |
| character(len=*),intent(in):: | EventName |
| integer(POINTER_KIND),intent(in):: | PEventHndlr |
| integer(HRESULT_KIND),intent(out),optional:: | iRet |
Arguments
EventSink [Input]
A handle to an event sink object with an active connection to an outgoing interface.
EventName [Input]
The name of an event in the outgoing interface of the Automation object to which the event sink is connected.
PEventHndlr [Input]
The memory address of a Fortran function that will be called each time the event sink object receives the event identified by EventName. See comments for more information.
iRet [Output/Optional]
Upon return, iRet contains S_OK or an error code.
Comments
This subroutine is used to indicate to the event sink object what Fortran function must be called each time the Automation object fires an event. After a call to EventSinkRegEvnt, the indicated Fortran function (PEventHndlr) will be executed each time EventName is fired, until EventSinkUnregEvnt is called to unregister the Fortran function.
If the outgoing interface to which the sink object is connected does not provides the event passed in argument EventName, subroutine EventSinkRegEvnt returns an error condition in argument iRet.
Argument PEventHndlr
This argument is the memory address of the Fortran function that works as an event handler. Fortran event handlers must have the following calling signature:
function FortranEventHndler(DispID, nArgs, VarArgList, nNamedArgs, &
DispIDList)
integer(HRESULT_KIND):: FortranEventHndler
integer(LONG_KIND),intent(in)::DispID
integer(LONG_KIND),intent(in)::nArgs
type(VARIANT),intent(inout)::VarArgList(nArgs)
integer(LONG_KIND),intent(in)::nNamedArgs
integer(LONG_KIND),intent(in)::DispIDList(nNamedArgs)
end function FortranEventHndler
Although the name of the function and its arguments can be different, the function’s signature (i.e. the function’s return type, and the type and ordering of the arguments) must be the same. All Fortran functions called by a sink object in response to events fired by an Automation object must have this call signature, or unexpected errors will occur. EventSinkRegEvnt does not check the calling signature of the Fortran function passed in PEventHndlr, so it is the responsibility of the programmer to do so.
You can register the same Fortran function to respond to one or more events. If you register more than one Fortran function for the same event, only the last Fortran function registered will be executed when the event is fired.
Examples
See Example 6.5 (Chapter 6 - User Manual).
Related Topics
| For information about: | See: | |
| Creating an event sink object | EventSinkCreate | |
| Connecting an event sink to a connectable object | EventSinkConnect | |
| Unregistering Fortran event handlers | EventSinkUnregEvnt | |
| Listing events exposed by a connected event sink object | EventSinkEnumEvnts | |