EldoS
MsgConnect home / Documentation / MessageHandler.OnMessage event
Navigation
Web site
Support
Table Of Contents

Filter: C++  Pascal  ActiveX  C#  VB.NET  Java SE  Java ME  Palm  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 *MCHandleMessageEvent)(void* UserData, void* Sender, MCMessage& Message, bool& Handled);
    MCHandleMessageEvent getOnMessage(void * *UserData);
    void setOnMessage(MCHandleMessageEvent v, void* UserData = NULL);

[Pascal]
    property OnMessage: TMCHandleMessageEvent
    TMCHandleMessageEvent = procedure (Sender :TObject; var Message : TMCMessage; var Handled : boolean) stdcall of object;

[VB6]
    Event IMCXQueueEvents.OnMessage(Message As IMCXMessage, Handled As Boolean)

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

[C#]
    public MCHandleMessageEvent OnMessage;

    public delegate void MCHandleMessageEvent(object Sender, MCHandleMessageEventArgs Args);

    public class MCHandleMessageEventArgs:EventArgs
    {
        public MCMessage Message;
        public bool Handled;
    }

[VB.NET]
    Public Event OnMessage As MCHandleMessageEvent
    Public Delegate Sub MCHandleMessageEvent(ByVal Sender As Object, ByVal Args As MCHandleMessageEventArgs)
    Public Class MCHandleMessageEventArgs
        Public Message As MCMessage
        Public Handled As Boolean
    End Class

[Java]

    public class MCHandleMessageEvent {
        public MCQueue getSender();
        public MCMessage getMessage();
    }
    public abstract interface MCHandleMessageListener {
        public boolean handleMessage(MCHandleMessageEvent e);
    }
    void addMessageListener(MCHandleMessageListener l);
    void removeMessageListener(MCHandleMessageListener l)

[Java ME]

    public class MCHandleMessageEvent {
        public MCQueue getSender();
        public MCMessage getMessage();
    }
    public abstract interface MCHandleMessageListener {
        public boolean handleMessage(MCHandleMessageEvent e);
    }
    void addMessageListener(MCHandleMessageListener l);
    void removeMessageListener(MCHandleMessageListener l)

[Palm]
    typedef void (STDCALLCONV *MCHandleMessageEvent)(void* UserData, void* Sender, MCMessage& Message, bool& Handled);
    MCHandleMessageEvent getOnMessage(void * *UserData);
    void setOnMessage(MCHandleMessageEvent v, void *UserData = NULL);

[DLL]
    void __stdcall MCMessageHandlerSetOnMessage(HMCMessenger h, HandleMessageProc Code, long UserData);
    void __stdcall MCMessageHandlerGetOnMessage(HMCMessenger h, HandleMessageProc* Code, long* UserData);
    void (__stdcall *HandleMessageProc)(long UserData, HMC Reserved, MCMessage 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 MCMemFree function. New block is allocated with MCMemAlloc function. Message.DataSize field should then be set to the size of the new block.
    [Pascal] NOTE: Delphi/Kylix IDE creates an event handler automatically, but it misses "stdcall" modifier. If you do not place "stdcall" manually for event handler function, it will crash.

See also:     MCMessage structure     Queue class     MCMemAlloc     MCMemFree    

 
Contact Us | Subscribe | Terms of Use | Trademarks | Privacy Statement
Copyright (c) 1998-2005, EldoS Corporation