MapWinGIS_TLB.pas Problems with Delphi XE5


#1

I am having trouble getting the new MapWinGIS into Delphi XE5.

I have tried bringing in the supplied “MapWinGIS_TLB.pas” file but there are errors highlighted in the code.

I get this:

"_Unit "MapWinGIS_TLB.pas" references the “Visual Component Library” framework, but the project currently has no framework assigned. Do you want to enable the “Visual Component Library” framework for this project?
(Not enabling the proper framework may require unit scoping, ambiguities, and linkage to framework binaries to be handled manually)
Yes No Cancel
---------------------------

I select “Yes” then I get a compile/build error on the “begin” line in the following function
function TShapefile.SelectShapes(const BoundBox: IExtents; Tolerance: Double;
SelectMode: SelectMode; var result: OleVariant): WordBool;
begin
Result := DefaultInterface.SelectShapes(BoundBox, Tolerance, SelectMode, result);
_end;__”

I would be very grateful if anyone has an answer to this.

Best regards
James


#2

Hi James,

The TLB.pas was made by importing the MapWinGIS.ocx file (v 4.9.6.1) into Delphi 10.1 (Berlin) using the Import Component option. After that, I went through and changed all the component type names, adding the Tmw prefix to names (Mapwin had a bunch of components with names like “table” that are already used in other Delphi units).

I’m not exactly sure why you are getting the build error, but I suspect it is due to namespaces being handled differently in XE5 vs Delphi Berlin. In particular, you may need the “Vcl.” namespace prefix added to some of your units - just a wild guess! (BTW - I think you didn’t tell us what the actual compile error message is did you?). Not sure also what version of Windows you are using and whether you are compiling 32- or 64-bit Delphi compiler.

Overall, I think you have two options:

  1. Re-import the OCX into your own version of Delphi and do what I did to rename components in the created TLB.pas file, or
  2. Play around with prefixes to your units. See this post which gives some further info on this:

Finally, a quick word of encouragement. Once you get it properly embedded in Delphi Mapwingis.ocx seems to work great. I’d be happy to keep interacting with you about its use in Delphi as there’s not many of us trying that I believe! I’m using it as part of a larger program that does modeling of air pollution and its impacts. See: www.energycommunity.org You can reach me here: charlie.heaps@sei.org.

Good luck!

Charlie


#3

Hi Charles

Thanks for the advice.

When I get some time I’ll give it a go.


#4

Hi Charlie

Still having trouble with this. I have imported the “OCX” which now appears as a bunch of components in the forms designer. I can drop these on the form. When I hit run the TLB code window opens stating “redeclaration of Result” error.

I am very inexperienced with importing TLB components… last time I did that successfully was to import some Excel_TLB stuff for excel automation… but that was 15 years ago in Delphi 7 on Windows XP.

I am currently on Delphi XE5 running on Win 10 Pro.

What sort of information do you need to advise me further (if you have the time and inclination - obviously)?


#5

Hi again James,

Sorry for the slow reply. I think the issue may be that Delphi itself (or your app) already has objects declared with that name and so MapWinGis components are clashing with your current code. I noticed that MapWinGIS has components that use names that are already in common use in Delphi, like “table”, “image” and “grid”. I dealt with this by manually editing the MapWinGIS_TLB file and giving ALL the high level components the prefix “Tmw” (e.g. TmwGrid). This worked well.

Take a look at the edited code at the end of the unit that registers all the components with Delphi:

RegisterComponents(dtlServerPage, [TmwShapeEditor, TmwGrid, TmwGridHeader, TmwESRIGridManager, TmwImage, TmwShape, TmwShapefile, TmwExtents, TmwPoint,
TmwTable, TmwField, TmwShapeNetwork, TmwUtils, TmwVector,
TmwGridColorScheme, TmwGridColorBreak, TmwTin, TmwShapeDrawingOptions, TmwLabels,
TmwLabelCategory, TmwLabel, TmwShapefileCategories, TmwShapefileCategory, TmwCharts,
TmwChart, TmwColorScheme, TmwChartField, TmwLinePattern, TmwLineSegment,
TmwGeoProjection, TmwGlobalSettings, TmwTiles, TmwTileProviders, TmwMeasuring,
TmwShapeValidationInfo, TmwFieldStatOperations, TmwFileManager, TmwOgrDatasource, TmwOgrLayer, TmwUndoList, TmwIdentifier, TmwSelectionList, TmwDrawingRectangle, TmwGdalRasterBand, TmwHistogram, TmwGdalDataset, TmwGdalDriver, TmwGdalDriverManager, TmwFunction, TmwExpression, TmwWmsLayer, TmwGdalUtils]);


#6

HI Charlie

Thanks for getting back to me.

So if I get the XXXXX_TLB.pas file and rename ALL the objects such as “TGridColorBreak” to “TmwGridColorBreak”, as you listed above I might be onto a winner?

Would a simple search and replace do it for me do you think?