Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: FoxPro FAQ


How to create a VFP DLL to use Mapquest in a VFP application. by Mike Gagnon
Posted: 4 Jan 04 (Edited 5 Jan 04)

Note: This technique can be also done using a VFP class rather then a DLL.
Note 2 :MapQuest is a website that allows you to find a portion of a map that contains the address,city, country and zip code requested. This has been tested for Canada and the US.
  1. Create a directory with Windows Explorer and call the directory "mapquest".

  2. In FoxPro poit the default directory to the "mapquest" directory. Tolls->Options->File locations->Default directory.

  3. Create a blank project (do not use the project wizard), and call the project "mapquest".

  4. Add a custom class (called "internet").

  5. Add 3 methods to the custom class (searchURL,showdestination,URLencode).

  6. In the 'searchURL" method put the following code:
    oBrowser = CREATEOBJECT("internetexplorer.application")
    oBrowser.visible = .t.

  7. In the 'showDestination' method put the following code:
    LPARAMETERS lcStreet,lcCity,lcState,lcZip,lcCountry
    IF EMPTY(lcStreet)
     lcStreet = ""
    IF EMPTY(lcState)
       lcState = ""
    IF EMPTY(lcZip)
       lcZip = ""
    IF EMPTY(lcCountry)
       lcCountry = "US"
    IF EMPTY(lcCity)
    this.searchurl("http://www.mapquest.com/maps/map.adp?country=" + ;
           lcCountry + "&addtohistory=&address=" + ;
           this.UrlEncode(lcStreet) + ;
           "&city=" + this.UrlEncode(lcCity) + "&state=" + ;
           this.UrlEncode(lcState) +  "&zipcode=" + ;
           this.UrlEncode(lcZip) + "&homesubmit=Get+Map&size=big")

  8. In the URLencode method put (this code was borrowed from www.West-Wind.com):
    LPARAMETERS  tcValue, llNoPlus
    LOCAL lcResult, lcChar, lnSize, lnX
    FOR lnX=1 to len(tcValue)
       lcChar = SUBSTR(tcValue,lnX,1)
       IF ATC(lcChar,"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") > 0
          lcResult=lcResult + lcChar
       IF lcChar=" " AND !llNoPlus
          lcResult = lcResult + "+"
       lcResult = lcResult + "%" + RIGHT(transform(ASC(lcChar),"@0"),2)
    RETURN lcResult

  9. Close the project. Open the class browser and load the internet class library and right-mouse on it and set it to OLEPublic. && This is required for a DLL

  10. Re-open the project and compile it using the "multi-threaded COM server DLL."

  11. Now you are ready to call the DLL to locate a portion of a map on mapQuest, using the 4 required parameters. In the command window try:
    oMap = NEWOBJECT("mapquest.internet")
    oMap.ShowDestination("134 ave Willobank","Pointe-claire","QC",;

  12. P.S. If the DLL is to be used on a user's computer rather than the development computer, the DLL needs to be registered.

    Mike Gagnon

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close