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 5 of 5

MapPoint 2006 with ActiveX

This is a discussion on MapPoint 2006 with ActiveX within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, i'm using c#.net, i made a wrapper for the ocx Visual Studio prompt: aximp <ocx-file> /source /keyfile:<key-file> the key ...

  1. #1
    jasanite is offline Member Yellow Belt
    Join Date
    Jul 2007
    Posts
    45

    MapPoint 2006 with ActiveX

    Hi,
    i'm using c#.net, i made a wrapper for the ocx
    Visual Studio prompt:
    aximp <ocx-file> /source /keyfile:<key-file>
    the key doesn't matter, output are two files
    1. AxMapPoint.dll
    2. MapPoint.dll
    First i got the Problem that the ActiveX needed
    a parent

    using AxMapPoint;

    AxMappointControl mapPoint = new AxMappointControl();
    form1.Controls.Add(mapPoint);
    mapPoint.NewMap(2);

    if you use something like this on a simple Form it's no problem.

    I made a class for using the Control and want to
    use it for calculation even without displaying.
    i got a form, simply said MyForm form1 = MyForm()
    then i give the ControlCollection of the Form.Panel to the Class
    an do following things (ControlCollection controls):

    AxMappointControl mapPoint = new AxMappointControl();
    controls.Add(mapPoint);
    mapPoint.NewMap(2);
    ...
    form1.Show(); //not in the class, just to show that i try to display
    the form afterwards

    On the NewMap() Operation it bangs.
    Little bit of testing showed that if i make the Form Visible and
    do Operations like NewMap and Calculate everything works
    finy, but as soon as the form isn't visible no Operation works.
    It's not the problem that something crashs but i want to
    calculate distances of Routes even without displaying.

    Additional:
    First i used an Activator to call MapPoint.Application.EU.13
    and did InvokeMember calls to use it, calculation and
    everything works fine, but i can't display it. 2 Ways of doing
    things for each part but they don't work together. I read
    about the object model but in c#.net there is just a
    Application interface, can't figure it out how this should work.
    I think that i use the object model with the Activator but
    little do i know ^^.

    (can't paste the whole code because of interfaces, factory
    and other stuff that i need for the project to make
    mappoint an optional part, but the problem is quite simple)

    I would like to use the OCX without displaying the Form
    but can't find a solution. Thanks for help.

  2. #2
    jasanite is offline Member Yellow Belt
    Join Date
    Jul 2007
    Posts
    45

    Re: MapPoint 2006 with ActiveX

    Oh, btw, if you need code of the Activator part etc. just post a request here.
    (maybe enriches the forum)
    It's just the problem that i need Late Binding for this project, but it works
    somehow, just the control struggles. And the helpfiles aren't very helpfull.
    Most parts are in VB and things you can't use in c#.

  3. #3
    jasanite is offline Member Yellow Belt
    Join Date
    Jul 2007
    Posts
    45

    Thumbs up Re: MapPoint 2006 with ActiveX

    Hi there, no, i won't write "I got the solution, thanks, bye".

    The problem was that the activeX wasn't completly
    initialized, in which way ever the show method of the
    form called the EndInit() Method of the ActiveX and made
    the usage afterwards possible.

    Solution: Just call it yourself.
    Form myForm = new Form();
    AxMappointControl mapPoint = new AxMappointControl();
    myForm.Controls.Add(mapPoint);
    mapPoint.EndInit(); // <- That's the way
    mapPoint.NewMap(MapPoint.GeoMapRegion.geoMapEurope );
    myForm.Show();

    Sry for my bad and irritating english, i'm german an not quite
    used to write or talk in english. Hope this helps some of you.

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: MapPoint 2006 with ActiveX

    Hi,

    I should work without the endInit(). Here I use an existing control. Maybe that is the reason:

    Code:
    public SnapToRoad(Control Owner, GeoMapRegion mapRegion)
    {
        owner = Owner;
        mp = new AxMapPoint.AxMappointControl();
        owner = Owner;
        owner.Controls.Add(mp);
        mp.NewMap(mapRegion);
        map = mp.ActiveMap;
    }
    Dont forget to destroy it when you don't need it anymore:

    Code:
    ~SnapToRoad()
    {
        Dispose(false);
    }
    
    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }
    
    protected virtual void Dispose(bool disposeManagedResources)
    {
        if (!disposed) {
    	if (disposeManagedResources) {
    	    map.Saved = true;
    	    owner.Controls.Remove(mp);
    	    mp.Dispose();
    	    mp = null;
    	    map = null;
    	}
    	disposed = true;
        }
    }

  5. #5
    jasanite is offline Member Yellow Belt
    Join Date
    Jul 2007
    Posts
    45

    Re: MapPoint 2006 with ActiveX

    Absolutely right, but activex wrapper and such stuff...
    if you have the problem, just do the above, normal
    usage won't need it ... but if you use it different the
    control will bite you

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VC++ doesn't find MapPoint 2006 ActiveX control
    By DrNobody in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 02-22-2007, 10:41 AM
  2. Mappoint 2006 ActiveX Questions
    By ben_dillon in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 01-31-2007, 07:16 AM
  3. FInd center location of ZipCode area using MP ActiveX (MP 2006)
    By Ekas in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 01-26-2007, 10:46 AM
  4. Difference between MapPoint 2006 and MapPoint 2006 Fleet
    By jlewis in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-21-2006, 09:18 AM
  5. mapPoint 2006 activex control slow down form closing
    By bule in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 09-26-2006, 02:22 PM

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