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

How to use external .dll, .tlb in VFP

Status
Not open for further replies.

olegs

Programmer
Jun 2, 2004
1
US
Hi All,
I am new to VFP, so the question may look very simple and naive, but any how.
I am trying to implement Microsoft MapPoint 2004 into already written application (VFP 6.0).
I need to use MapPoint dll (MPNA82.tlb) located in
c:\Program Files\Microsoft MapPoint\mpna82.tlb
1.
if it try to use DECLARE command

DLL_PATH = "C:\Program Files\Microsoft MapPoint\"
fTemp = DLL_PATH + "mpna82.tlb"
DECLARE INTEGER Application IN &fTemp

It is not working, can't get the path
DECLARE INTEGER Application IN mpna82.tlb
also is not working because the path is not right.

Also, MapPoint has 3 classes
Application
Map
MapPointUtilities

Each class has its own methods/functions which I need to use in order to create a map. For Example
Map class has
AttPushin(AtLocation, Name)
ZoomIn()
ZoomOut()
etc.

Method AddPushpin(AtLocation As Location, Name As String) As Pushpin
Member of MapPoint.Map
Adds a Pushpin to the map in the My Pushpins set.

Method ZoomIn() As Void
Member of MapPoint.Map
Zooms the map view closer.

Method ZoomOut() As Void
Member of MapPoint.Map
Zooms the map view farther out.

etc......

The question is, How should I declare these methods in VFP?
Also with DECLARE function?
Do I have to list dll.class.function?

Could anyone, please, give me a syntax or example how to use third parties dll/tlb/ocx in VFP.

Thank you in advance

Oleg
 
Is the dll registered?

You may spot something of use (including how to register it) in dll related FAQs:

Build a .NET DLL and use it in VFP faq184-3836
How to create a DLL in VFP faq184-3381
Protect your apps/functions with a dll faq184-4964
How to create a VFP DLL to use Mapquest in a VFP application. faq184-4666
 
DECLARE is used for Win32 DLLs. You need to find the class name you need and then instantiate it with CREATEOBJECT(), as you're working with a COM server.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports"
 
Hi Olegs,

Welcome to the forum, and to VFP. Your question is not at all naive ... on the contrary.

As Craig suggested, MapPoint is a COM server (also known as an Automation server), and so the DECLARE statement is not appropriate. Instead, you instantiate it as an object, like so:

oMP = CREATEOBJECT("Mappoint.Application")

You can then access its properites and methods by reference to the oMP object. For example, the following code gets a reference to the active map and searches for an address:

oMap = oMP.ActiveMap
oLoc = oMap.FindAddress("Address goes here")

This is a very simple example, but I hope it gives you a start.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
To add to the information you have already received, if you update to VFP 7 or 8 (or the soon to be released public beta of 9.0!), you'll get the advantage of Intellisense and the Object Browser to better explore COM server object models and their PEMs.

Rick
 
Hi Oleg,

Along with what has already been said:
DECLARE INTEGER Application IN &fTemp
This will fail because of the spaces in the path. You either need to use name expression (fTemp) or surround it with quotes "&fTemp.".

Regards,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top