Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I'm defeated. I may have to sell shoes!
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01564407
Message ID:
01564483
Vues:
66
>Replace WAIT WINDOW calls with the following code. Check if it will work for you.
>
>DECLARE INTEGER MessageBox IN user32 As MsgBox;
>	INTEGER hWindow, STRING lpText,;
>	STRING lpCaption, INTEGER wType
>
>= MsgBox(0, "Message Text", "Message Caption", 0x1232)
>
Here is the original code sample from MSDN. The problem I'm having is in the "Setup the event handler to receive messages"

** This demo shows sending messages asynch with event handler
#INCLUDE MSMQ.H

CLEAR

PUBLIC oComUtil, oFoxEvents, oRecQueue, oMSMQEvent

LOCAL oQueueInfo,oMsg,lcQueueName

lcQueueName = "myEventQueue"

oQueueInfo = CreateObject("msmq.msmqqueueinfo")
IF CheckOffline()
* Private Queue
oQueueInfo.Formatname = "DIRECT=OS:.\PRIVATE$\"+lcQueueName
ELSE
* Public Queue
oQueueInfo.Formatname = "DIRECT=OS:.\"+lcQueueName
ENDIF

* Setup up event handler to receive the messages
oMSMQEvent = create("msmq.msmqevent")
oComUtil = create("vfpcom.comutil")
oFoxEvents = create("foxevent")
oComUtil.BindEvents(oMSMQEvent,oFoxEvents)
oRecQueue = oQueueInfo.Open(MQ_RECEIVE_ACCESS,MQ_DENY_NONE)
oRecQueue.EnableNotification(oMSMQEvent,MQMSG_CURRENT,1000)

* Add a bunch of new message
oSendQueue = oQueueInfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
oMsg = create("msmq.msmqmessage")
oMsg.AppSpecific = 11
oMsg.Label = "Message11 - " + TRANS(DATETIME())
oMsg.Send(oSendQueue)
oMsg.AppSpecific = 22
oMsg.Label = "Message22 - " + TRANS(DATETIME())
oMsg.Send(oSendQueue)
oMsg.AppSpecific = 33
oMsg.Label = "Message33 - " + TRANS(DATETIME())
oMsg.Send(oSendQueue)
oMsg.AppSpecific = 44
oMsg.Label = "Message44 - " + TRANS(DATETIME())
oMsg.Send(oSendQueue)
oMsg.AppSpecific = 55
oMsg.Label = "Message55 - " + TRANS(DATETIME())
oMsg.Body = "This is body of message 55."
oMsg.Send(oSendQueue)
oSendQueue.Close

* We need to leave Queue open and events bound.
* oComUtil.UnBindEvents(oMSMQEvent,oFoxEvents)
* oRecQueue.Close

DEFINE CLASS foxevent AS custom

lReceiveAll = .T.
Procedure Arrived(oQueue,Cursor)
oMsgRec = oQueue.PeekCurrent(,,0)
? "Message Arrived Event: "+TRANS(oMsgRec.AppSpecific),oMsgRec.Label
IF oMsgRec.AppSpecific = 33 OR THIS.lReceiveAll &&get only this one
oMsgRec = oQueue.ReceiveCurrent(,,,0)
oMsgRec = oQueue.PeekCurrent(,,0)
oQueue.EnableNotification(oMSMQEvent,MQMSG_CURRENT,1000)
ELSE
oQueue.EnableNotification(oMSMQEvent,MQMSG_NEXT,1000)
ENDIF
ENDPROC

Procedure ArrivedError(Queue,ErrorCode,Cursor)
? "Message Arrived Error"
ENDPROC

ENDDEFINE
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform