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
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Integrating MapPoint control into a VC++ application

This is a discussion on Integrating MapPoint control into a VC++ application within the MapPoint Desktop Discussion forums, part of the Map Forums category; One more try, could somebody help: I want to use MapPoint Control in my VC++ FormView based application. In the ...

  1. #1
    geouser is offline Junior Member Yellow Belt
    Join Date
    Jun 2006
    Posts
    13

    Integrating MapPoint control into a VC++ application

    One more try, could somebody help:
    I want to use MapPoint Control in my VC++ FormView based application. In the CFormView object there is the following code

    void CMapPointTest1View::OnInitialUpdate()
    {

    ..................

    VARIANT var;
    var.vt = VT_INT;
    var.intVal = 1;
    CMap1 map = m_MapPoint.NewMap(var);
    }

    m_MapPoint is the CMappointCtrl object to which I connected the MapPoint control element (CMappointCtrl object).
    A map appears. But once I click in it, MapPoint collapses. There must be a solution.
    Thanks! Jörg

  2. #2
    kristijan is offline Junior Member White Belt
    Join Date
    Nov 2005
    Posts
    7
    do you try to interact with the map in your source code when you click in it ?

  3. #3
    geouser is offline Junior Member Yellow Belt
    Join Date
    Jun 2006
    Posts
    13
    Not yet, what you see is the only code written. I click the map - and MapPoint collapses.

  4. #4
    Mohamed is offline Member Green Belt
    Join Date
    Mar 2005
    Posts
    97
    Hi,

    I've found the following code in this forum:
    I hope it gives some help


    Code:
    OK, this is what worked for me. 
    
    In your CMapPointCtrl class add this public function: 
    
    inline COleControlSite* GetCtrlSite() {return m_pCtrlSite;} 
    
    Remember that when you re-init your activeX control this file will get written over. 
    
    
    And then when you initiliaze the map do this: 
    
    SetCapture(); 
    // Open the MAP 
    VARIANT var; 
    var.vt = VT_INT; 
    var.intVal = 1; //geoMapUSA 
    CMap1 map = m_MapPoint.NewMap(var); 
    
    // This fixes the problem 
    m_pCtrlCont->OnUIDeactivate(m_MapPoint.GetCtrlSite()); 
    m_pCtrlCont->OnUIActivate(NULL); 
    SetFocus(); 
    
    ReleaseCapture();

  5. #5
    geouser is offline Junior Member Yellow Belt
    Join Date
    Jun 2006
    Posts
    13
    Yes, I've seen this already. But from where to hell does he/she get the
    m_pCtrlCont pointer?

  6. #6
    geouser is offline Junior Member Yellow Belt
    Join Date
    Jun 2006
    Posts
    13
    The following is the solution:

    1. Add the follwing function into the CMappointCtrl object:

    COleControlSite* CMappointCtrl::GetCtrlSite()
    {
    return m_pCtrlSite;
    } which returns the control site.

    2. Add #include "OccEx.h" into your FormView or Dialog object or where you want to display the map.

    3. In the FormView or Dialog add the following to OnInitialUpdate():

    void CMapPointTest1View::OnInitialUpdate()
    {
    ............................

    SetCapture();
    // Open the MAP
    VARIANT var;
    var.vt = VT_INT;
    var.intVal = 1; //geoMapUSA
    CMap1 map = m_MapPointCtrl.NewMap(var);

    // This fixes the problem
    m_pCtrlCont->OnUIDeactivate(m_MapPointCtrl.GetCtrlSite());
    m_pCtrlCont->OnUIActivate(NULL);
    SetFocus();

    ReleaseCapture();
    }

    m_pCtrlCont then returns the control container.
    It is stable (as far as I see now).

    Thanks to everyone

  7. #7
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Integrating MapPoint control into a VC++ application

    Hi guys,

    I've used this style of importing Mappoint, but when I close my app I get this:
    First-chance exception in MapPrac.exe (KERNEL32.DLL): 0x800706BE: (no name).

    And I've just used this code:
    Code:
    void CMapPracDlg::OnButtonStart() 
    {
     CMap1 map;
     map = m_Mappoint.GetActiveMap();
     
     CLocation loc;
     loc = map.GetLocation( 50.90695, 7.47828, 1 );
     CPushpin pushpin;
     pushpin = map.AddPushpin( loc.GetLocation(), "ID: Target" );
     pushpin.SetBalloonState(1);
     loc.GoTo();
     m_Mappoint.ShowWindow( 1 );
    }
    Everything works fine and the app doesn't collapse, but it just doesn't exits mappoint the right way.
    I hope somebody can explain this.

    Does somebody has experience with another way of importing Mappoint in VC++? e.g. importing the mappoint library? How can I show the map? Normally I've done this by importing ActiveX and VC++ autamatically generates a MapControl I can drag 'n drop where I want on my GUI, to display the map. With importing library I don't know how to do that. I've read the articles how to do that, but not how to show the map.

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

    Re: Integrating MapPoint control into a VC++ application

    Hi,

    Is this the object model that you use or do you have put the activeX control on your form ?

  9. #9
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Integrating MapPoint control into a VC++ application

    Thank you for your reply Wilfried,

    Well it's a bit fuzzy what ActiveX or COM is.
    But what I know is that ActiveX IS COM, the only difference is that ActiveX has wrapped a COM object so that it can be easely used by VB or VC++, especially VB (ActiveX was developed for VB, I've read once), those guys are spoiled to much .

    But I guess sometimes ActiveX works well for VB but not for VC++. I've imported Mappoint as an ActiveX, and it didn't work correctly, I had to add some code's I've copied from a post of someone here on this forum (I don't remember which one it is). That was a workaround, but I don't know if it was correct, I had no choice. Maybe that's why MS has no documents on how to use Mappoint with VC++.

    Another way to import Mappoint, is to import it's library .tlb into VC++. I haven't tried this way yet, but maybe this way is a better way.

    But does somebody imported Mappoint as an ActiveX without First Exception for terminating Mappoint?

    Thank you.

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

    Re: Integrating MapPoint control into a VC++ application

    Hi,

    Ok, I think this article explain some use with the type library (what I meant with the object model), as whell the activex control:

    Using the OCX from VC++

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. integrating Mappoint into my home grown application
    By sam_ahn612 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-14-2005, 11:34 AM
  2. Integrating MapPoint map into VB.Net App
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-22-2003, 02:49 PM
  3. Where to get MapPoint Control for Installing Application
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-11-2003, 10:25 PM
  4. Mappoint control in an Office Application using VBA
    By ToddRCS in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-19-2002, 05:00 PM
  5. Mappoint 2002 - can a control not an application ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-14-2001, 06:58 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