Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot connect to ActiveX. 2

Status
Not open for further replies.

PANTLORD

Programmer
Aug 28, 2001
49
EU
Hi there,

I have written an ActiveX control using Delphi called dummyprint.ocx. If I embed this as an OLEControl after registering it in Powerbuilder I can access it fine using the dummyprint.object. notation and it behaves as expected.

I do not wish to embed it though I would rather create an OLEObject within a script and access it this way i.e. OLEOBject dummy_print
dummy_print= CREATE OLEObject
li_rtn = intermec_print.ConnectToNewObject("C:\DummyPrint.ocx")
intermec_print.object.++++and so on

however I keep getting a return of -2 when I try to connect so I haven't connected correctly and consequently cannot access any properties / functionality.

Any ideas ?

Thanks
Niall
 
To instantiate an external control in PowerScript, I guess you should be using a DLL version of your utility rather than OCX. OCX/ActiveX controls are visual objects.

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
Thanks for the reply found out what the problem was just there now.

I was referencing my ocx incorrectly. When I have it registered I needed to go to the Powerbuilder browser and then the OLE tab, within there in OLE Custom Controls I see my activex and can grab the ProgId from the Class Information so it sould have read...

OLEOBject dummy_print
dummy_print= CREATE OLEObject
li_rtn = intermec_print.ConnectToNewObject("DummyPrintControl1.DummyPrint")
intermec_print.

Also there is no need for the .object notation when referenced in this manner.

Cheers
Niall
 
Yes! That is the right way to 'spell' the control rather than use its full-path. We do it the same way when we connect to a database using the Driver attribute of the dBParm of a transaction object.

However, you should use the VersionIndependentProgID if there is one under its Class Information instead of ProgID. VersionIndependentProgID is a generic way of using an external-control in that it uses the latest installed version on the machine at runtime. If VersionIndependentProgID does not exist for your OCX under its Class Information, ProgID will be fine.

Good luck...

---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
Thanks for this,

I checked there and this OCX doesn't have the version independent id so I'll have to stick with the one I have now.

On a slightly different note I need to deploy this ocx with some code. I have manually registered it locally on my own powerbuilder but am unsure how to automatically register it. If I register it in windows will powerbuilder automatically have it also ? with the ID I have coded ?

Guess I am trying to find out how best to deploy it and get it self registering with the code release, any ideas ?

Thanks
Niall
 
PantLord,

The OCX will not be auto-installed on the users' machines just because it is referenced in your PowerBuilder code - you will have to do it yourself. In that context, it is similar to a DLL. You have a couple of options to automate installing/registering it on the users' machines:

1. Let the installer do it for you. For this try the FREE and the best installer:


There is also a GUI tool for this nice utility:


2. Every OCX has an inbuilt method: DLLRegisterServer() that can be declared as a local external function:

FUNCTION long DLLRegisterServer() LIBRARY &quot;<your-ocx.ocx>&quot;

Then, in the Constructor! event of your OCX, just make a call to:

This.DLLRegisterServer()

This approach is sometimes more ideal when normal registration gives some problems of not getting registered properly:



---
PowerObject!
-----------------------------------------
PowerBuilder / PFC Developers' Group
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top