Searching for a Specific High-Level Event
Searching for a Specific High-Level Event
Sometimes you do not want to accept the next available high-level event
pending for your application. Instead, you might want to select one such event
from among all the high-level events in your application's high-level event
queue. For example, you might want to look for a return receipt for a
high-level event you previously posted before processing other high-level
events.
You can select a specific high-level event by calling the function
GetSpecificHighLevelEvent. One of the parameters you pass to this
function is a filter function that you provide. Your filter function should
examine an event in your application's high-level event queue and determine if
that message is the kind of event you wish to receive. If it is, your filter
function returns TRUE. This indicates that your filter function does not want to
inspect any more events. If the filter function finds an event of the desired
type, it should call AcceptHighLevelEvent to retrieve it. When your
function returns TRUE, the function GetSpecificHighLevelEvent itself
returns TRUE.
If your filter function returns FALSE for an event in the high-level
event queue, then GetSpecificHighLevelEvent looks at the next event in
the high-level event queue and executes your filter function. If the filter
function returns FALSE for all the high-level events in the queue, then
GetSpecificHighLevelEvent itself returns FALSE to your application.
Here's how you declare the filter function whose address you pass to
pascal Boolean aFilter (void * yourDataPtr,
HighLevelEventMsgPtr msgBuff,
const TargetID *sender)
The yourDataPtr parameter indicates the criteria your function should use to
search for a specific event. The msgBuff parameter contains a pointer to a
high-level event message record that has the HighLevelEventMsg structure.
When you call GetSpecificHighLevelEvent and it executes your filter
function for a high-level event waiting in the high-level event queue, the
fields of HighLevelEventMsg are filled in by the Event Manager. You can then
compare the fields of this record to the information you pass in the
yourDataPtr parameter to determine if that event suits your needs. For
example, the yourDataPtr parameter might contain the signature of a return
receipt. You can test its value against the EventClass contained in the
theMsgEvent field of the high-level event message record.