MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
I've whipped up a quick MapWinGIS Visual C++ example upon request and I am posting it here for anyone else who may be interested in trying it out. Good luck to you all and I hope this helps. Sorry about the formatting, I guess the Phorum software thinks it knows more about code
Visual C++ MapWinGIS Example
Posted by:
Darrel Brown ()
Date: November 21, 2003 06:46PM
I've whipped up a quick MapWinGIS Visual C++ example upon request and I am posting it here for anyone else who may be interested in trying it out. Good luck to you all and I hope this helps.
Sorry about the formatting, I guess the Phorum software thinks it knows more about code formatting than I do :)
/* This is a very basic example of how to use the MapWinGIS components in c++.
Create an empty console application then paste in the following code. */
/* Written by Darrel Brown, 11/21/2003
I built this example using MS VS.net 2002 */
#include <stdio.h>
/* imports the MapWinGIS.ocx control so we can use it in this application */
#import "c:\\dev\\InstallImage\\v3.0\\MapWinGIS.ocx" named_guids
/* Without this statement I would have to fully qualify all references to MapWinGIS objects or members
such as the CLSID_Shapefile and IID_IShapefile members. If you don't want to use the MapWinGIS
namespace you can simply say MapWinGIS::CLSID_Shapefile and MapWinGIS::IID_IShapefile. */
using namespace MapWinGIS;
int main()
{
/* interface used to access shapefile properties and methods */
MapWinGIS::IShapefile *sf;
/* Initialize this application for com access */
/* Microsoft says to use CoInitializeEx, but it didn't work in this very simple application. */
CoInitialize(NULL);
/* create an instance of a shapefile object */
CoCreateInstance(CLSID_Shapefile, NULL, CLSCTX_INPROC_SERVER, IID_IShapefile, (void**)&sf);
/* Open the shapefile then display how many shapes are in it. */
if (sf->Open("c:\\dev\\data\\states.shp", NULL) == VARIANT_FALSE)
{
printf("Failed to open the shapefile, exiting now.");
return -1;
}
else
{
printf("This shapefile has %d shapes in it.\n", sf->NumShapes);
return 0;
}
}
Sorry about the formatting, I guess the Phorum software thinks it knows more about code formatting than I do :)
/* This is a very basic example of how to use the MapWinGIS components in c++.
Create an empty console application then paste in the following code. */
/* Written by Darrel Brown, 11/21/2003
I built this example using MS VS.net 2002 */
#include <stdio.h>
/* imports the MapWinGIS.ocx control so we can use it in this application */
#import "c:\\dev\\InstallImage\\v3.0\\MapWinGIS.ocx" named_guids
/* Without this statement I would have to fully qualify all references to MapWinGIS objects or members
such as the CLSID_Shapefile and IID_IShapefile members. If you don't want to use the MapWinGIS
namespace you can simply say MapWinGIS::CLSID_Shapefile and MapWinGIS::IID_IShapefile. */
using namespace MapWinGIS;
int main()
{
/* interface used to access shapefile properties and methods */
MapWinGIS::IShapefile *sf;
/* Initialize this application for com access */
/* Microsoft says to use CoInitializeEx, but it didn't work in this very simple application. */
CoInitialize(NULL);
/* create an instance of a shapefile object */
CoCreateInstance(CLSID_Shapefile, NULL, CLSCTX_INPROC_SERVER, IID_IShapefile, (void**)&sf);
/* Open the shapefile then display how many shapes are in it. */
if (sf->Open("c:\\dev\\data\\states.shp", NULL) == VARIANT_FALSE)
{
printf("Failed to open the shapefile, exiting now.");
return -1;
}
else
{
printf("This shapefile has %d shapes in it.\n", sf->NumShapes);
return 0;
}
}
Re: Visual C++ MapWinGIS Example
Posted by:
Kehinde Isijola ()
Date: May 22, 2012 09:39AM
Hello sirs,
I am having problem with this example. I get 4 Compiler errors like this:
1>c:\...\mapwingis.tlh(4377) : error C2535: 'long MapWinGIS::IImage::GetOriginalHeight(void)' : member function already defined or declared
1> c:\...\mapwingis.tlh(4368) : see declaration of 'MapWinGIS::IImage::GetOriginalHeight'
and 4 compiler errors like this
1>c:\...\mapwingis.tlh(9851) : error C2366: 'MapWinGIS::IImage::GetOriginalHeight' : redefinition; different implementation_key specifiers
1> c:\...\mapwingis.tlh(4368) : see declaration of 'MapWinGIS::IImage::GetOriginalHeight'
Pls people with similar experience should help.
I am doing this in MFC code with CFormView.
I am having problem with this example. I get 4 Compiler errors like this:
1>c:\...\mapwingis.tlh(4377) : error C2535: 'long MapWinGIS::IImage::GetOriginalHeight(void)' : member function already defined or declared
1> c:\...\mapwingis.tlh(4368) : see declaration of 'MapWinGIS::IImage::GetOriginalHeight'
and 4 compiler errors like this
1>c:\...\mapwingis.tlh(9851) : error C2366: 'MapWinGIS::IImage::GetOriginalHeight' : redefinition; different implementation_key specifiers
1> c:\...\mapwingis.tlh(4368) : see declaration of 'MapWinGIS::IImage::GetOriginalHeight'
Pls people with similar experience should help.
I am doing this in MFC code with CFormView.
Sorry, only registered users may post in this forum.


