Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 3 of 3

Can a MapPoint control be conditionall loaded or late bound?

This is a discussion on Can a MapPoint control be conditionall loaded or late bound? within the MapPoint Desktop Discussion forums, part of the Map Forums category; Greetings, all. I have an application which is using the MapPoint control for doing some routing. It works very well. ...

  1. #1
    frankp is offline Junior Member White Belt
    Join Date
    Dec 2003
    Posts
    10

    Can a MapPoint control be conditionall loaded or late bound?

    Greetings, all.

    I have an application which is using the MapPoint control for doing some routing. It works very well. The issue is an Access Violation is raised when the application is launched on a machine on which MapPoint isn't installed.

    Is there a way to verify that MapPoint is, in fact, installed and then instantiate the control? I really don't want to have to maintain two versions of this application! FWIW, the app is written in Delphi.

    Phil Frank

  2. #2
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Re: Can a MapPoint control be conditionall loaded...

    Hello,
    I successfully used this in VB 6.
    (MyRegistry is my class to read Registry keys, you can try something similar...)

    -------------------------------------------------
    Code:
    Private Function TestMapPointInstallation(sVersion As String, sRegion As String) As Boolean
    
        Dim bOK As Boolean
        Dim sKey As String
        Dim sPath As String
        Dim aRegistry As New MyRegistry
        Dim d As Drive
        
        sKey = "Software\Microsoft\MapPoint\" & sVersion & "\" & sRegion
        bOK = aRegistry.ReadKey(HKEY_CURRENT_USER, sKey, "InstallTo", sPath)
        If Not bOK Then
            Exit Function
        End If
        sPath = sPath & "Data\" & sRegion & "_CD.mad"
        bOK = g_TheFso.FileExists(sPath)
        If Not bOK Then
            bOK = aRegistry.ReadKey(HKEY_CURRENT_USER, sKey, "DataPath", sPath)
            If Not bOK Then
                Exit Function
            End If
            sPath = sPath & "\" & sRegion & "_CD.mad"
            
            bOK = g_TheFso.FileExists(sPath)
            If Not bOK Then
                For Each d In g_TheFso.Drives
                    If d.DriveType = CDRom Or d.DriveType = Remote Then
                        sPath = d.DriveLetter & Right(sPath, Len(sPath) - 1)
                        bOK = g_TheFso.FileExists(sPath)
                        If bOK Then
                            Exit For
                        End If
                    End If
                Next
            End If
        End If
        g_bMapPointInstallationOK = bOK
        TestMapPointInstallation = bOK
    
    End Function
    
    Public Function InitializeMapPointControl() As Boolean
    
        Dim bOK As Boolean
    
        If g_bMapPointInstallationTested Then
            bOK = g_bMapPointInstallationOK
        Else
            g_nMapPointVersion = 11
            bOK = TestMapPointInstallation(CStr(g_nMapPointVersion) & ".0", "EUR")
            If Not bOK Then
                g_nMapPointVersion = 9
                bOK = TestMapPointInstallation(CStr(g_nMapPointVersion) & ".0", "EUR")
            End If
            g_bMapPointInstallationTested = True
        End If
        If Not bOK Then
            GoTo EH
        End If
    
        On Error Resume Next
        Licenses.Add "MapPoint.Control." & g_nMapPointVersion
    
        On Error GoTo EH
        Set theMapPoint = Controls.Add("MapPoint.Control." & g_nMapPointVersion, "theMapPoint", Me)
    
        ' Move the control where you want...
        theMapPoint.Move 0, 0, Width, Height
        theMapPoint.Visible = True
      
        theMapPoint.NewMap geoMapEurope
    
        InitializeMapPointControl = True
    
    EH:
    
    End Function

  3. #3
    frankp is offline Junior Member White Belt
    Join Date
    Dec 2003
    Posts
    10
    Stefano:

    Thanks for your code sample. When I finally get this to work I'll give you a credit for this part of the application.

    Phil Frank

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Re: Keyboard control in mappoint activex control
    By djcapslock in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-10-2005, 11:16 AM
  2. Using MapPoint Control for Web App
    By Attila in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-11-2005, 10:36 AM
  3. i need the mappoint control 9 please
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 04-22-2004, 10:41 AM
  4. disable loaded pin sets in mappoint 2002
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-22-2003, 09:52 PM
  5. I am using MapPoint Control in another Ac....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-23-2001, 09:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96