Embedding MapPoint within MFC VC++

How to embed MapPoint as a control

I'll give some clues how to embed MapPoint into an dialog based application using MFC.

We'll start with a new project...

... called web_example. It will be dialog based...

... nothing special here.

I always static link. I'd have enough "DLL Hell" in my time. OK for this example it won't matter. But there's a principle at stake.

Before you know it we have a default dialog box to edit. So stay in the editor, and delete the static control.

Now we insert the MapPoint Control. Right Click...

and choose the MapPoint Control...

Position the control...

We now need the ClassWizard. Right-click once more....

We'll add the control as a member variable in our dialog class.

Click "Add Variable..."

...and choose the MapPointControl. We get this warning dialog:

Click OK. The following dialog appears. I've left the defaults as is.

Finally we get back to adding the member variable...

Now we do a tiny bit of coding. Add #include "map.h" to the dialog cpp file.

and this tiny bit to the OnInitDialog() member function:

a.vt = VT_I4;
a.lVal = 2; // geoMapEurope!


Compile, run and behold:

We've done so well haven't we! 


Move the mouse pointer over the dialog....


This assertion is fixed by my code elsewhere! File: occcont.cpp Line: 385



Other VC++ source here.

Back to the Mapping page