Filter: C++  Pascal  C#  VB.NET  Java  Java ME  ActiveX  DLL 



MessageHandler.OnMessage

MessageHandler     See also    


This event is fired when the message code for the message fits into range of messages handled by the object.

Declaration

[C++]
    typedef void (STDCALLCONV *IPCHandleMessageEvent)(void* UserData, void* Sender, IPCMessage& Message, bool& Handled);
    IPCHandleMessageEvent getOnMessage(void * *UserData);
    void setOnMessage(IPCHandleMessageEvent v, void* UserData = NULL);

[Pascal]
    property OnMessage: TIPCHandleMessageEvent
    TIPCHandleMessageEvent = procedure (Sender :TObject; var Message : TIPCMessage; var Handled : boolean) of object;

[VB6]
    Event IIPCXQueueEvents.OnMessage(Message As IIPCXMessage, Handled As Boolean)

[ActiveX]
    void IIPCXQueueEvents.OnMessage([in] IIPCXMessage * Message, [in, out] VARIANT_BOOL * Handled);

[C#]
    public IPCHandleMessageEvent OnMessage;

    public delegate void IPCHandleMessageEvent(object Sender, IPCHandleMessageEventArgs Args);

    public class IPCHandleMessageEventArgs:EventArgs
    {
        public IPCMessage Message;
        public bool Handled;
    }

[VB.NET]
    Public Event OnMessage As IPCHandleMessageEvent
    Public Delegate Sub IPCHandleMessageEvent(ByVal Sender As Object, ByVal Args As IPCHandleMessageEventArgs)
    Public Class IPCHandleMessageEventArgs
        Public Message As IPCMessage
        Public Handled As Boolean
    End Class

[Java]
    public class IPCHandleMessageEvent {
        public IPCQueue getSender();
        public IPCMessage getMessage();
    }
    public abstract interface IPCHandleMessageListener {
        public boolean handleMessage(IPCHandleMessageEvent e);
    }
    void addMessageListener(IPCHandleMessageListener l);
    void removeMessageListener(IPCHandleMessageListener l)

[Java ME]
    public class IPCHandleMessageEvent {
        public IPCQueue getSender();
        public IPCMessage getMessage();
    }
    public abstract interface IPCHandleMessageListener {
        public boolean handleMessage(IPCHandleMessageEvent e);
    }
    void addMessageListener(IPCHandleMessageListener l);
    void removeMessageListener(IPCHandleMessageListener l)

[DLL]
    void __stdcall IPCMessageHandlerSetOnMessage(HIPCMessenger h, HandleMessageProc Code, long UserData);
    void __stdcall IPCMessageHandlerGetOnMessage(HIPCMessenger h, HandleMessageProc* Code, long* UserData);
    void (__stdcall *HandleMessageProc)(long UserData, HIPC Reserved, IPCMessage Message, bool* Handled);

Parameters

  • [DLL]h - handle to the MessageHandler object that was returned by MessageHandlers.Add method
  • [DLL]Code - pointer to the callback function that is called to handle the message

  • UserData - application-defined data that is passed back to the callback function
  • Message - the message that was sent with given credentials.
  • Handled - set this value to true to tell the queue that the message was handled and false otherwise

Description

    This event is fired when the handler is to handle the incoming message. If the application receives a message via this event, it should NOT call Messenger.MessageProcessed method -- the queue will do this automatically.
    Set Handled to true to tell the messenger that the message was processed. If the message was not processed, the queue will attempt to find another handler and finally call OnUnhandledMessage event. If OnUnhandledMessage also doesn't handle the message, messenger will set Message.Result to 0.
    It is safe to change the data pointed by Message.Data parameter. If Message.MessageType is BDT_VAR, such changes will be sent back to the message sender. If the application needs to change the size of the data, it can deallocate existing memory block (if any) using IPCMemFree function. New block is allocated with IPCMemAlloc function. Message.DataSize field should then be set to the size of the new block.

See also:     IPCMessage structure     Queue class     IPCMemAlloc     IPCMemFree