PDA

View Full Version : Integratin MapPoint ActiveX control into VC++ 6.0



geouser
06-04-2006, 01:46 PM
Hi, could someone help me:
I am a beginner in using MapPoint ActiveX control. I've integrated MapPoint control into my MFC project and a lot of MapPoint specific wrapper classes are added to my project. First step will be to make a US map appear on the screen after the user clicks my application's menu. I've tried this (following a suggestion given on MP2K forum - thank you for this one):

The user clicks the menu and the following routine will be processed:

void CMapPointTestView::OnMappoint()
{
CMappointCtrl MapPoint;
VARIANT var;
var.vt = VT_INT;
var.intVal = 1; //geoMapUSA
CMap1 map = MapPoint.NewMap(var);

}

It has to be somthing using an instance of CMappointCtrl calling NewMap(). But no map appears. Instead, I get an error message! :(
Can someone help me?
Thanks in advance...

Wilfried
06-04-2006, 02:49 PM
Hi,

What is the error message ?

geouser
06-05-2006, 09:44 AM
Hi Wilfried:

It is a dialog box from the VC++ Debug Library saying: Debug Assertion failed [as I run the debug mode]
File: winocc.cpp
Line: 345 [which is the ASSERT-call in CWnd::InvokeHelper(..) ]

If i click 'Ignore' another dialog box appears saying something like: Test.exe has a problem and has to be stopped.



Jörg

Wilfried
06-05-2006, 02:22 PM
Hi,

But you are using the activeX component. I do not understeand the code. What is wrong calling the name of the component with the newMap method ? Or is there something I do no see ?

kristijan
06-07-2006, 04:58 AM
hiho
i have also an active x object in a vc++ programm and a wrapper class around it. THis is my code where i create the object and do show the map.


m_Map = new CControl1;
m_Map->Create(NULL, WS_VISIBLE, r, CWnd::FromHandle(dlg_App.m_hWnd), 2001);
VARIANT newMap;
VariantInit(&newMap);
V_VT(&newMap) = VT_I4;
V_I4(&newMap) = m_Map->geoMapEurope;
m_Map->NewMap(newMap);


where the variable m_Map is a in my class defined
as
CControl1 *m_Map;
and the CControl1 is the wrapper class around the idl stuff, library.

i also encountered the problem that it is necessary that the interaction with the controll has to be in the main message handler.
i did define the m_map variable also in the class of my application, because you have to be very carefull with every object you create from the control. (it has to be released when you are done with operating).

Besides this i have 2 questsions->
First Problem is : how can i deactivate the right mous button menu ? I don't want to show a menu at all.

Second problem : Where is my callback function where i can track mappoint actions ?

geouser
06-07-2006, 07:15 AM
Hi Wilfried, Kristijan :

The problem with my code above was (at least)

CMappointCtrl MapPoint;

I forgot to connect the CMapPointCtrl instance to the MapPoint ActiveX control element implemented into the view-object. So what I have now is

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

where m_MapPoint is a member variable of CMapPointTestView which has to be connected to the MapPoint control element (using the wizzard).

The map appears now but the program collapses once I click in it or change the window size.

So Kristijan: Thanks for your suggestion. I will try your code.

Jörg

geouser
06-07-2006, 02:42 PM
Second problem : Where is my callback function where i can track mappoint actions ?

Im not sure whether I understand your queston:
You will have to catch theWnd messages coming from your ActiveX control element. The possibilities are displayed if you open MFC class wizzard and click the object-ID to which you have connected your ActiveX control (for example: IDC_CONTROL1). In the 'messages' display you will find the messages coming back from your control.

Wilfried
06-13-2006, 03:11 PM
Hi,

I think that you mean the events from the component ? There are a lot of events where you can assign event handlers to. Like MouseMove, SelectionChange, etc...