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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX Object

Status
Not open for further replies.

codenavigator

Programmer
Jun 14, 2002
14
US
I have an ActiveX server executable that is functional in VB, and its interface is viewable in the object browser of VFP 7.0, but I am unable to instantiate an object using CREATEOBJECT(). Is there a way to use its classes in Visual Foxpro?
 
Can you post the syntax to instanciate it in VB and the code u use to instanciate it in VFP? Walid Magd
Engwam@Hotmail.com
 
The code in VB is:

Code:
Public oModbusServer As ModbusSrv
Set oModbusServer = New ModbusSrv

In VFP, I have tried:
Code:
(1)     oModbusServer = CREATEOBJECT("ModbusSrv")
(2)     oModbusServer = CREATEOBJECT("ModbusServer.ModbusSrv")
Both of these VFP statements result in the error "class definition...cannot be found".

The ActiveX executable is called MBServer.exe; the type library is called ModbusServer.tlb. Both are stored in the Windows/System directory.

 
In VB after you define your object, type the object name then dot '.' to get list of the PEMs for this object.
If you find Application is one of interface, try
oModbusServer = CREATEOBJECT("ModbusSrv.Application")
Most of the times the Application object is the gate for the interface.
Walid Magd
Engwam@Hotmail.com
 
One more thing you can try, Tools Options, Controls, ActiveX
Find your ActiveX check it and save as default.
In the form controls tool bar click the classes button - the one look like books - and stay with the mouse in each one of them to read the tip. If you find your control just drag it and drop it in your from this will make an automatic CreateObject for you. Give it a name and start using it with this name. Walid Magd
Engwam@Hotmail.com
 
Application is not included in the public interface. Only properties and functions specific to the class are visible.
 
That is the oddity. The class does not appear in the ActiveX controls list, although it is visible in VFP's object browser and in VB references.
 
Well add it to the ActiveX controls window, I believe you got add feature in this window. Walid Magd
Engwam@Hotmail.com
 
I have tried and have gotten an error message, "...file does not exist".
 
Have you registered the file with REGSVR32? Until you do this, I'm pretty sure Visual FoxPro cannot use it.

Ian
 
Ian,
If it is not registered, how VB can 'SEE' it?! Walid Magd
Engwam@Hotmail.com
 
The file was registered with windows. Because it is an executable, it was registered using the syntax:

Code:
MBServer.exe /RegServer
 
Walid,

I don't know the first thing about VB, actually, so my question was just for information. If it doesn't show up in the ActiveX controls list, I assumed it wasn't registered.

What you might be able to do is add the control to a test form from the VFP Object Browser, then look at the properties of the OLE control. See what the OLEClass property contains. That would be the string you need to specify in the CREATEOBJECT() line.

Another possibility would be to open up the Registry Editor and do a search for "ModbusSrv" in HKEY_CLASSES_ROOT. That could also tell you what string to put in the CREATEOBJECT() command.

Hope that helps,

Ian
 
Thanks for the help. The class was identified in the registry as "modbussrv.modbussrv.1".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top