How to receive events from objects?

Re: How to receive events from objects?

Postby Antonio Linares » Mon Jun 16, 2014 1:31 am

And here an example of use:

__axRegisterHandler( o:__hObj, {| ... | MsgInfo( ... ) } )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to receive events from objects?

Postby Jose Dolar » Mon Jun 16, 2014 6:14 am

Antonio,

The topic was posted sometime in 2008. :)

Sounds great that it is there, but I'm getting a link error :(.

What is the library file and where to get the MyInclude.ch?

BTW I used it this way: oOle:=OleWEvent():New(cProgId)

Regards, Saludos

Jose
Jose Dolar
 
Posts: 52
Joined: Thu Mar 22, 2012 5:43 pm
Location: USA

Re: How to receive events from objects?

Postby Antonio Linares » Mon Jun 16, 2014 7:40 am

Jose,

As I have explained, it seems as you don't need that library at all :-)

Simply try to use this:
__axRegisterHandler( o:__hObj, {| ... | MsgInfo( ... ) } )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to receive events from objects?

Postby Jose Dolar » Mon Jun 16, 2014 8:27 am

Antonio,

I didn't notice the info on the second page. I tried to follow the code in the prg sample. :)

But my application terminated after the Alert("here") :(

Error -2147220992 WINOLE/1014 Failed to obtain connection point: __AXREGISTERHANDLER Args: (P:0x484EA9C) (B:{|| ... })

Thanks,

Jose



Method Instantiate_Device(cProgID) class OPOSHardwareInterface
local oOle:='',n
::lDeviceInstantiated:=.f.
oOle:=CreateObject(cProgID)
if valtype(oOle)='O'
::lDeviceInstantiated:=.t.
alert('Here')
__axRegisterHandler( oOle:__hObj, {| a,b,c | MsgInfo( 'Test') }) && What are the parameters of the codeblock?
aadd(::aoDevices,oOle)
* aadd(::aoDevices,oOle:oOleAuto)
endif
return oOle
Jose Dolar
 
Posts: 52
Joined: Thu Mar 22, 2012 5:43 pm
Location: USA

Re: How to receive events from objects?

Postby Antonio Linares » Mon Jun 16, 2014 8:49 am

Please check this value:

MsgInfo( oOle:__hObj )

and let me know it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to receive events from objects?

Postby Jose Dolar » Mon Jun 16, 2014 2:44 pm

The valtype (oOle:__hObj) is P

The value differs as shown below.

OS Error -2147220992 WINOLE/1014 Failed to obtain connection point: __AXREGISTERHANDLER Args: (P:0x2CDAD04)
OS Error -2147220992 WINOLE/1014 Failed to obtain connection point: __AXREGISTERHANDLER Args: (P:0x30DA6CC)
Jose Dolar
 
Posts: 52
Joined: Thu Mar 22, 2012 5:43 pm
Location: USA

Re: How to receive events from objects?

Postby Antonio Linares » Mon Jun 16, 2014 3:28 pm

Jose,

Please try suplying the third parameter: cIID

function __AXREGISTERHANDLER( pDisp, bHandler [, cIID] ) --> pSink

What are the parameters of the codeblock?


"..." means "whatever it is supplied". We may get different amount of params for an event based on the used OLE object.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to receive events from objects?

Postby Jose Dolar » Mon Jun 16, 2014 7:11 pm

Antonio,

What is cIID?

If cIID is the ole program ID (cProgID in my code) then I tried that and my up terminated.

error: WINOLE/1014 Failed to obtain connection point: __AXREGISTERHANDLER Args: (P:0x473A43C) (B:{|| ... }) (C:OPOS.POSPrinter)

Thanks,

Jose
Jose Dolar
 
Posts: 52
Joined: Thu Mar 22, 2012 5:43 pm
Location: USA

Re: How to receive events from objects?

Postby Antonio Linares » Mon Jun 16, 2014 9:58 pm

Jose,

have you started the cIID with '{' ?

It must start with '{' and end with "}"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to receive events from objects?

Postby Jose Dolar » Tue Jun 17, 2014 2:27 am

Hi Antonio,

What is {cIID}? A new syntax? Looks like an array..

Anyway I tried both as shown below and still resulted to the same error

Thanks,

Jose

Method Instantiate_Device(cProgID) class OPOSHardwareInterface
local oOle:='',n,cIID
::lDeviceInstantiated:=.f.
oOle:=CreateObject(cProgID)
if valtype(oOle)='O'
::lDeviceInstantiated:=.t.
alert(valtype(oOle:__hObj))
alert('Here')
*__axRegisterHandler( oOle:__hObj, {| ...| MsgInfo( 'Test') },{cProgID}) && What are the parameters of the codeblock?
__axRegisterHandler( oOle:__hObj, {| ...| MsgInfo( 'Test') },{cIID}) && What are the parameters of the codeblock?
alert('Done')
aadd(::aoDevices,oOle)
* aadd(::aoDevices,oOle:oOleAuto)
endif
return oOle
Jose Dolar
 
Posts: 52
Joined: Thu Mar 22, 2012 5:43 pm
Location: USA

Re: How to receive events from objects?

Postby Jose Dolar » Tue Jun 17, 2014 2:55 am

Antonio,

Do I need to include the oleWEvents0.c and oLeWEvents.prg to my App?

Thanks,

Jose
Jose Dolar
 
Posts: 52
Joined: Thu Mar 22, 2012 5:43 pm
Location: USA

Re: How to receive events from objects?

Postby Antonio Linares » Tue Jun 17, 2014 5:27 am

Jose,

You don't have to include those files in your app.

Here you can read about cIID:
cIID
Specifies the Interface ID GUID of cCLSID | cPROGID when you create an early bound instance of the class. If you pass an empty string as cIID Visual FoxPro attempts to access the default interface (IID) of cCLSID | cPROGID.
Example

x = CREATEOBJECTEX("excel.application","",;
"{000208D5-0000-0000-C000-000000000046}")


The "{" and "}" are part of the name. They are not related to arrays, etc.

We are not going to use it (like the above example) in CreateObject(). We just use it from __axRegisterHandler()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to receive events from objects?

Postby Jose Dolar » Tue Jun 17, 2014 8:19 am

Antonio,

OK, I found cIID, but still got the following error. I also send you a screen shot of my COM viewer where I got cIID (I can't find attach option here). Please check. Thanks.

Error: OS Error -2147220992 WINOLE/1014 Failed to obtain connection point: __AXREGISTERHANDLER Args: (P:0x484F564) (B:{|| ... }) (C:{B196B284-BAB4-101A-B69C-00AA00341D07})

Thank you,

Jose

Code: Select all  Expand view
Method Instantiate_Device(cProgID) class OPOSHardwareInterface
local oOle:='',n
local ciid:='{B196B284-BAB4-101A-B69C-00AA00341D07}'  && <-- IconnectionPointContainer
::lDeviceInstantiated:=.f.
oOle:=CreateObject(cProgID)
if valtype(oOle)='O'
    ::lDeviceInstantiated:=.t.
if cprogid='OPOS.POSPrinter'
alert(ciid)
__axRegisterHandler( oOle:__hObj, {| ...| MsgInfo( 'Test') },ciid) && <-- IconnectionPointContainer
alert('Handler registered')
endif
    aadd(::aoDevices,oOle)
endif
return oOle
Last edited by Jose Dolar on Tue Jun 17, 2014 6:39 pm, edited 4 times in total.
Jose Dolar
 
Posts: 52
Joined: Thu Mar 22, 2012 5:43 pm
Location: USA

Re: How to receive events from objects?

Postby Antonio Linares » Tue Jun 17, 2014 11:06 am

Jose,

Welcome to the nightmare of the OLE objects... :-S

Here you have the source code for __AXREGISTERHANDLER()

https://github.com/harbour/core/blob/master/contrib/hbwin/axcore.c

Check its code please, you will see there are just two places where it is checked. If it does not work, then I am afraid that very little we can do, except if you contact that OLE tech support service and show them the source code (in axcore.c) that you are using.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to receive events from objects?

Postby Jose Dolar » Tue Jun 17, 2014 7:41 pm

Antonio,

I agree, this might be beyond Harbour as Carlos was successful using this function with a different OLE service.

Or may be it's just the version of my compiler.

I am still using Harbour 2.1. I checked the logs and there was many changes related to axcore.c to date. I hope one of these changes fixed this issue..

Thank you for your support. I appreciate it. :)

Saludos,

Jose
Last edited by Jose Dolar on Sun Jun 22, 2014 5:39 pm, edited 1 time in total.
Jose Dolar
 
Posts: 52
Joined: Thu Mar 22, 2012 5:43 pm
Location: USA

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: byron.hopp, Google [Bot] and 29 guests