Page 1 of 1

about Comat event handler: how to register specified event ?

Posted: Thu Feb 19, 2009 11:13 am
by john lory
I wan't process flash ocx event ,the code like bellow:

Code: Select all

  FlashObject = COMate_CreateObject("ShockwaveFlash.ShockwaveFlash", GadgetID(winhd) )
Debug FlashObject
  If FlashObject
    FlashObject\SetEventHandler(@myEventCallback()) 
....
the flash ocx 's flashcall event prototype is:

Code: Select all

Public Event FlashCall(ByVal request As String) As String
It requires a string value as return , so i write event handler procedure is:

Code: Select all

Procedure.s myEventCallback(object.COMateObject, eventName.s, parameterCount)  
If eventName = "OnReadyStateChange" 
ElseIf eventName = "FlashCall"
  Debug "FlashCall,param count:" + Str(parameterCount) + ":command:" +object\GetStringEventParam(1) + ",args :" + object\GetStringEventParam(2)
  [b]ProcedureReturn "<string>ok</string>"[/b]
ElseIf eventName = "OnProgress" 
ElseIf eventName = "FSCommand"
  Debug "FSCommand  ,param count:" + Str(parameterCount) + ",request :"+object\GetStringEventParam(1)
Else
    Debug " woo,unknown event for flash ocx"
EndIf
but when i run the app, the flash can't receive the return value:"<string>ok</string>"
it is a bug for COMate?

additional, Comate SetEventHandler function register all control's event to the handler, but how i register a specified event to ONE PB's procedure? like

Code: Select all

 ...
comateObj\SetEventHandler("event name",@eventHandler)? 
for flashcall event :

Code: Select all

...
FlashObject\SetEventHandler("FlashCall",@flashCallHandler())
....
;;flashcall event handler
procedure.s  flashCallHandler(....)
...
procedurereturn "return value"
endprocedure
....
perhapse,it is a GOOD function to PB coder :D


Comate is a great works!!

Posted: Thu Feb 19, 2009 11:38 am
by srod
COMate is set up to send all events to the one event procedure (this is essentially how ActiveX controls function anyhow); from here you can do what you want with them. If you wish to employ individual event procedures then you will need to code this yourself; I don't really see a problem.

COMate cannot return values from event procedures; mostly because I have not as yet encountered an ActiveX control which requires this. Most take return values through one of the parameters being sent BYREF, which COMate can handle. Adding explicit returns from event handlers will be fiddly. The easiest way would be for COMate to pass the event handler a variant structure into which the client application would be required to pass the appropriate return value etc. This avoids COMate having to worry about the type of return required etc. Before I can do this, however, I need access to an example in which an event handler is allowed to make some kind of return value and the means to test my resulting additions to COMate. If you can supply me with a demo (a flash demo would be fine, though I'd need one which fires these events) which I can work with then I'll see what I can do?

Posted: Fri Feb 20, 2009 12:58 am
by srod
@John Lory :

please see the latest update to COMate in which I have added all that you were after.

I must point out though that, from what I have seen on the web, the "FlashCall" event exposed by the Shockwave object does not have a return value! I may have misunderstood what I was reading (as it was MFC code etc.) but I thought I'd point this out anyhow. :)

Posted: Sat Feb 21, 2009 2:17 pm
by john lory
:shock: your are SUPERMAN ,srod, so quickly you replied .
sorry for my mistake,flashcall event have NOT return value :oops:
thanks you works!!

Posted: Sat Feb 21, 2009 6:48 pm
by john lory
srod ,for flashcall api detail information, refer bellow links please:
http://osflash.org/pipermail/osflash_os ... 02274.html
http://osflash.org/ext_howto

the calling flow:
...
register host (python,c#) callback function for flash flashcall event,
flash fire the flashcall event
execute host callback function and return result to flash
....
it is my thinking, is it right?

Posted: Sun Feb 22, 2009 1:00 pm
by john lory
srod wrote:@John Lory :

please see the latest update to COMate in which I have added all that you were after.

I must point out though that, from what I have seen on the web, the "FlashCall" event exposed by the Shockwave object does not have a return value! I may have misunderstood what I was reading (as it was MFC code etc.) but I thought I'd point this out anyhow. :)
you are right ,srod,flash control flashcall event has NO return value!
I made a mistake :? :oops: in fact ,the return value is returned by call flash other function :SetReturnValue in event process method,code like:

Code: Select all

....
Procedure.s Flashcall_handler(object.COMateObject, eventName.s, parameterCount)    
  ;;;;do some logic here and return value 
   ret$="<string>ok</string>"
  
    object\invoke("SetReturnValue('" + ret$ + "')"); 
  ProcedureReturn ret$
EndProcedure 
.....

  If FlashObject 
    FlashObject\SetEventHandler("Flashcall",@Flashcall_handler()) 
....
thank you for your works :P