ChrisO
Registered User.
- Local time
- Today, 19:25
- Joined
- Apr 30, 2003
- Messages
- 3,202
G’day all.
Here is another curious demo which may be of some use.
-------
The definition of a Subscribing Form as used here: -
A Form which has code to receive, and respond to, an Event raised by a process.
A subscribing Form may also generate the Event process.
A subscribing Form must be either open or instantiated.
-------
The attached download (Access 2003) demonstrates how to do an event broadcast to all Forms which subscribe to the event. The subscribing Forms may be open Forms or instances of a Form, such as sub-Forms.
In the demo the source of the event request is the master Form, frmMain0. frmMain0 has two buttons which raise separate requests for a broadcast namely, SetColours and SetFilter. This request is sent to SendBroadcast in class clsBroadcast.
Class clsBroadcast raises an event and passes two arguments, the Broadcast name and an optional argument.
If a subscribing Form, or instance of a subscribing Form, detects the broadcast event it responds by passing back, to class clsBroadcast, three arguments namely, Me, strBroadcast and vntArg.
Class clsBroadcast receives the three arguments in Sub ExecuteBroadcast. Subroutine ExecuteBroadcast uses strBroadcast to split the processing amongst other subroutines and passes the pointer to the calling Form and the optional argument. Each called subroutine then process the optional argument, if required, based on the pointer to the calling Form. (A pointer to the calling Form is used here because the name of the calling Form can not be used if the calling Form is an instance of a Form.)
Although this process may seem overly complex it really isn’t. There is not all that much code and it alleviates the code to have to call all other subscribing Forms be they open, instances of other Forms or closed.
Search Keywords:
Broadcast Event RaiseEvent WithEvents Source Sink Subscribe Subscribing
Regards,
Chris.
Here is another curious demo which may be of some use.
-------
The definition of a Subscribing Form as used here: -
A Form which has code to receive, and respond to, an Event raised by a process.
A subscribing Form may also generate the Event process.
A subscribing Form must be either open or instantiated.
-------
The attached download (Access 2003) demonstrates how to do an event broadcast to all Forms which subscribe to the event. The subscribing Forms may be open Forms or instances of a Form, such as sub-Forms.
In the demo the source of the event request is the master Form, frmMain0. frmMain0 has two buttons which raise separate requests for a broadcast namely, SetColours and SetFilter. This request is sent to SendBroadcast in class clsBroadcast.
Class clsBroadcast raises an event and passes two arguments, the Broadcast name and an optional argument.
If a subscribing Form, or instance of a subscribing Form, detects the broadcast event it responds by passing back, to class clsBroadcast, three arguments namely, Me, strBroadcast and vntArg.
Class clsBroadcast receives the three arguments in Sub ExecuteBroadcast. Subroutine ExecuteBroadcast uses strBroadcast to split the processing amongst other subroutines and passes the pointer to the calling Form and the optional argument. Each called subroutine then process the optional argument, if required, based on the pointer to the calling Form. (A pointer to the calling Form is used here because the name of the calling Form can not be used if the calling Form is an instance of a Form.)
Although this process may seem overly complex it really isn’t. There is not all that much code and it alleviates the code to have to call all other subscribing Forms be they open, instances of other Forms or closed.
Search Keywords:
Broadcast Event RaiseEvent WithEvents Source Sink Subscribe Subscribing
Regards,
Chris.