How to receive events from objects?
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to receive events from objects?
And here an example of use:
__axRegisterHandler( o:__hObj, {| ... | MsgInfo( ... ) } )
__axRegisterHandler( o:__hObj, {| ... | MsgInfo( ... ) } )
-
- Posts: 52
- Joined: Thu Mar 22, 2012 5:43 pm
- Location: USA
Re: How to receive events from objects?
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to receive events from objects?
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( ... ) } )
As I have explained, it seems as you don't need that library at all
Simply try to use this:
__axRegisterHandler( o:__hObj, {| ... | MsgInfo( ... ) } )
-
- Posts: 52
- Joined: Thu Mar 22, 2012 5:43 pm
- Location: USA
Re: How to receive events from objects?
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to receive events from objects?
Please check this value:
MsgInfo( oOle:__hObj )
and let me know it
MsgInfo( oOle:__hObj )
and let me know it
-
- Posts: 52
- Joined: Thu Mar 22, 2012 5:43 pm
- Location: USA
Re: How to receive events from objects?
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)
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)
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to receive events from objects?
Jose,
Please try suplying the third parameter: cIID
function __AXREGISTERHANDLER( pDisp, bHandler [, cIID] ) --> pSink
Please try suplying the third parameter: cIID
function __AXREGISTERHANDLER( pDisp, bHandler [, cIID] ) --> pSink
"..." means "whatever it is supplied". We may get different amount of params for an event based on the used OLE object.What are the parameters of the codeblock?
-
- Posts: 52
- Joined: Thu Mar 22, 2012 5:43 pm
- Location: USA
Re: How to receive events from objects?
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to receive events from objects?
Jose,
have you started the cIID with '{' ?
It must start with '{' and end with "}"
have you started the cIID with '{' ?
It must start with '{' and end with "}"
-
- Posts: 52
- Joined: Thu Mar 22, 2012 5:43 pm
- Location: USA
Re: How to receive events from objects?
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
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
-
- Posts: 52
- Joined: Thu Mar 22, 2012 5:43 pm
- Location: USA
Re: How to receive events from objects?
Antonio,
Do I need to include the oleWEvents0.c and oLeWEvents.prg to my App?
Thanks,
Jose
Do I need to include the oleWEvents0.c and oLeWEvents.prg to my App?
Thanks,
Jose
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to receive events from objects?
Jose,
You don't have to include those files in your app.
Here you can read about cIID:
We are not going to use it (like the above example) in CreateObject(). We just use it from __axRegisterHandler()
You don't have to include those files in your app.
Here you can read about cIID:
The "{" and "}" are part of the name. They are not related to arrays, etc.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}")
We are not going to use it (like the above example) in CreateObject(). We just use it from __axRegisterHandler()
-
- Posts: 52
- Joined: Thu Mar 22, 2012 5:43 pm
- Location: USA
Re: How to receive events from objects?
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
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
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.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to receive events from objects?
Jose,
Welcome to the nightmare of the OLE objects... :-S
Here you have the source code for __AXREGISTERHANDLER()
https://github.com/harbour/core/blob/ma ... n/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.
Welcome to the nightmare of the OLE objects... :-S
Here you have the source code for __AXREGISTERHANDLER()
https://github.com/harbour/core/blob/ma ... n/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.
-
- Posts: 52
- Joined: Thu Mar 22, 2012 5:43 pm
- Location: USA
Re: How to receive events from objects?
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
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.