Important: The information in this document is obsolete and should not be used for new development.
PostHighLevelEvent
You can use thePostHighLevelEventfunction to send a high-level event to
another application.
FUNCTION PostHighLevelEvent (theEvent: EventRecord; receiverID: Ptr; msgRefcon: LongInt; msgBuff: Ptr; msgLen: LongInt; postingOptions: LongInt): OSErr;
theEvent- The event to send. Your application should fill out the
what,message, andwherefields of the event record. Specify thekHighLevelEventconstant in thewhatfield, the event class of the high-level event in themessagefield, and the event ID in thewherefield. You do not need to fill out thewhenormodifiersfields; the Event Manager automatically assigns the appropriate values to these fields when you send the message.receiverID- The recipient of the high-level event. When sending an event to another application on the local computer, you can specify the recipient of the event by session reference number, process serial number, signature, or port name and location name. When sending an event to an application on a remote computer, you can specify the recipient only by the session reference number or by the port name and location name.
- To specify a port name and location name, provide the address of a target ID record in the
receiverIDparameter. To specify a process serial number, provide its address in thereceiverIDparameter. To specify a session reference number, or signature, provide the data (cast to thePtrdata type) in thereceiverIDparameter.msgRefcon- A unique number that identifies the communication associated with this event. Your application can set this field to any value it chooses. If you are replying to a high-level event, you should use the same value in the
msgRefconparameter as specified in the high-level event that originated the request.msgBuff- A pointer to a data buffer that contains any additional data for the event.
msgLen- The size (in bytes) of the data buffer pointed to by the
msgBuffparameter.postingOptions- Options associated with the
receiverIDparameter and delivery options associated with the event. You can specify one or more delivery options to indicate whether you want the other application to receive the event at the next opportunity and to indicate whether you want acknowledgment that the event was received by the other application. You use the options associated with thereceiverIDparameter to indicate how you are specifying the recipient of the event--whether by port name and location name in a target ID record, by session reference number, by process serial number, or by signature.- You can use a combination of these constants in the
postingOptionsparameter:CONST nAttnMsg = $00000001; {give this message priority} nReturnReceipt = $00000200; {return receipt requested} receiverIDisTargetID = $00005000; {ID is port name and location name} receiverIDisSessionID = $00006000; {ID is PPC session reference number} receiverIDisSignature = $00007000; {ID is creator signature} receiverIDisPSN = $00008000; {ID is process serial number}DESCRIPTION
ThePostHighLevelEventfunction posts the high-level event to the specified process.If the application to which you are sending a high-level event terminates, you receive
the result codesessionClosedErrthe next time your application callsPostHighLevelEventto send another high-level event to the terminated application. If you do not care about any state information about that session, you can just resend your event. Otherwise, you must restart another session and resend your event.If your application is running in the background and posts a high-level event that requires the network authentication dialog box to be displayed,
PostHighLevelEventreturns thenoUserInteractionAllowedresult code, does not display the network authentication dialog box, and does not send the event. If your application receives thenoUserInteractionAllowedresult code, you can use the Notification Manager to inform the user that your application needs attention. When the user brings your application to the foreground, you can repost the event. If the reposting is successful, your application can continue to post high-level events without further user interaction. Note thatPostHighLevelEventcan returnnoUserInteractionAllowedonly on the first posting of a high-level event to a remote target.SPECIAL CONSIDERATIONS
ThePostHighLevelEventfunction may move or purge memory. You should not call this function from within an interrupt, such as in a completion routine or VBL task.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for thePostHighLevelEventfunction are
Trap macro Selector _OSDispatch $0034 SEE ALSO
For details on how to send Apple events to other applications using theAESendfunction, see Inside Macintosh: Interapplication Communication.RESULT CODES
noErr 0 No error connectionInvalid -609 Connection is invalid noUserInteractionAllowed -610 Cannot interact directly with user sessionClosedErr -917 Session closed