Platform: All Win32 Platforms
Category: Code Samples
Using MapX with Borland C++.
What modifications are necessary to use MapX with Borland C++?
MapX needs the MFC header files and the nafxcw.lib, available in Borland C++ 5.02.
There are only a few items in the header files which need to be resolved before MFC and VCL can be used in the same program (i.e. Microsoft Foundation Classes in a Borland C++ Builder program). Here they are:
1. AFXV_W32.H (131) AND WINREG.H (39) conflict over definition of HKEY
Change AFXV_W32.H by commenting out the lines below. This causes HKEY to default to being a WORD as in WINREG .
typedef struct HKEY__ *HKEY;
2. afxwin.h 798 & 793 Multiple declare of CDC::DrawState
3. afxwin.h 1247, 1250, 1253, 1283 , 1286 ambiguities in "IUnknown" etc. resolved by "::"; in other words, the typedef should always use the local structure not the MFC definition.
Apparently, this is not polymorphically two distinct routines due to the equivalence of some typedefs or #defines.
Comment out one of the routine definitions. Also, comment out afxwin1.inl 686 because "Body already defined" for the same reason.
4. afxwin1.inl 554 cannot convert long to void *
Needs explicit cast of lpData to (void *)
5. afxdisp.h 597, 743 747 more ambiguity resolved by :: (i.e. ::IClassFactory2, not IClassFactory2)
Additionally, a -Vf has to be added to each project makefile by hand (MFC compatibility), as does a reference to the MFC link library (nafxcw.lib, in your Borland C++ 5.02 /lib directory). Also, include MapX.cpp in the project for link purposes.
The only other problem is that the Borland structure (i.e. TMap) cannot be cast to the actual type for the control (in this case CMapX). To get a CMapXLayers structure, etc, use the structure constructor that expects an LPDISPATCH - for instance:
/* Usually a map is dropped on the form
and this statement is not needed
TMap Map = new TMap;
CMapXLayers Layers = new CMapXLayers((LPDISPATCH) (Ole2::IDispatch *) Map->Layers);
This has to be done, because the VCL for Map>Layers returns a System::Variant with an IDispatch * in it.
Last Modified: 07/31/2001 01:45:05 PM