MapPoint and Visual Studio 2010 Tutorial
Wilfried Mestdagh shows how to get started with Visual Studio 2010 and MapPoint 2010 development in this first of a two-part article.
Getting Started with MapPoint in Visual Studio 2010
Part 1: Using the object model
Wilfried Mestdagh's article shows how to use MapPoint in Visual Studio 2010.
Sometimes people think MapPoint's architecture is getting dated and has difficulties working with modern development tools. Well, nothing is less true. Every modern development tool is perfectly suited to do development with MapPoint. This article is a small tutorial on how to start with MapPoint in VS2010, using the object model.
This article assumes you have installed Visual Studio 2010 and MapPoint 2010 (or any other version).
We start the development tool and create a new windows forms application. First thing to do is to add the MapPoint type library to our project. To do this click right on 'References' in the Solution Explorer and then click 'Add' as shown below:
Next click the tab 'COM Components', then 'Microsoft MapPoint Control 17 type library' as shown below, then click 'OK'.
Now we add a few 'using' clause as shown below and then we can start:
Now we start coding a little. What it does is the following:
- Try to attach to a running instance of MapPoint. If no instance is running then we create a new one.
- Attach a Quit event handler. If someone closes MapPoint then we don't want to survive either.
- If we close then we close MapPoint also, but only if we have created the instance ourself.
- You see there a mysterious typecast. This is because there is a method 'Quit' and an event with the same name. Visual Studio takes the method as default, hence the typecast.
- Visual Studio as well as MapPoint have both an Application object. So we use full path of it to get the right one.
Now you are ready to code and let MapPoint do exacly what you want for your application. Happy coding :)