MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Integrating MapPoint control into a VC++ application

This is a discussion on Integrating MapPoint control into a VC++ application within the MapPoint 2006/2009 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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-11-2006
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 06-12-2006
Junior Member
White Belt
 
Join Date: Nov 2005
Posts: 7
Send a message via ICQ to kristijan
do you try to interact with the map in your source code when you click in it ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 06-12-2006
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 06-12-2006
Member
Green Belt
 
Join Date: Mar 2005
Posts: 96
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();
__________________
Mohamed
www.AtlasCouscous.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 06-12-2006
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 06-13-2006
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 02-12-2007
Member
Green Belt
 
Join Date: Nov 2006
Posts: 87
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 02-12-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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 ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 02-13-2007
Member
Green Belt
 
Join Date: Nov 2006
Posts: 87
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 02-13-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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++
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
application, control, integrating, mappoint


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
integrating Mappoint into my home grown application sam_ahn612 MapPoint 2006/2009 Discussion 1 03-14-2005 11:34 AM
Integrating MapPoint map into VB.Net App Anonymous MapPoint 2006/2009 Discussion 1 07-22-2003 02:49 PM
Where to get MapPoint Control for Installing Application Anonymous MapPoint 2006/2009 Discussion 1 01-11-2003 10:25 PM
Mappoint control in an Office Application using VBA ToddRCS MapPoint 2006/2009 Discussion 1 11-19-2002 05:00 PM
Mappoint 2002 - can a control not an application .... Anonymous MapPoint 2006/2009 Discussion 1 08-14-2001 06:58 AM


All times are GMT -5. The time now is 05:39 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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