How to change line style

jharding@mtaonline.net
Global Mapper User
Hello,
I am trying to change the line style of a loaded shape file but having problems. After reading through many threads. I am still not able to get it to work. Please help. Below is the code I have so far but I get an error that I
Cannot convert type 'GlobalMapperDLLWrapper.GM_LineStyle_t' to 'System.IntPtr'
Code:
GM_LineStyle_t tempLineStyle = newGM_LineStyle_t();
tempLineStyle.mPenStyle =
GM_PenStyle_t16.GM_PEN_DIAMONDS_RIGHT;
tempLineStyle.mPenWidth =
Convert.ToByte(2);
IntPtr tempLineStylePTR = (IntPtr)tempLineStyle;
GlobalMapperDLL.GM_SetLineFeatureDrawStyle(theLayerHandle, Convert.ToUInt32(5), tempLineStylePTR);
I am trying to change the line style of a loaded shape file but having problems. After reading through many threads. I am still not able to get it to work. Please help. Below is the code I have so far but I get an error that I
Cannot convert type 'GlobalMapperDLLWrapper.GM_LineStyle_t' to 'System.IntPtr'
Code:
GM_LineStyle_t tempLineStyle = newGM_LineStyle_t();
tempLineStyle.mPenStyle =
GM_PenStyle_t16.GM_PEN_DIAMONDS_RIGHT;
tempLineStyle.mPenWidth =
Convert.ToByte(2);
IntPtr tempLineStylePTR = (IntPtr)tempLineStyle;
GlobalMapperDLL.GM_SetLineFeatureDrawStyle(theLayerHandle, Convert.ToUInt32(5), tempLineStylePTR);
Comments
-
Try changing the declaration of the GM_LineStyle_t parameter from 'IntPtr' to 'ref GM_LineStyle_t', then you can just directly pass in the tempLineStyle value and the address will be taken automatically. The IntPtr declaration is only there to make it easier to pass in a NULL pointer to reset the style to default. In C# they hide all of the pointer stuff so you have to do things a bit differently to get the address out, you can't just cast.
Note I would also suggest calling GM_GetLineFeature to get the original line features, then copying the line style from that and changing what you want, then calling GM_SetLineFeatureDrawStyle and GM_FreeLineFeature on the line. That way you only change what you want about the style and not anything else, like the font.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation -
Thanks Mike, that worked.
Categories
- 12.5K All Categories
- 5.5K Features Discussion
- 314 Downloading Imagery
- 1.3K Elevation Data
- 377 Georeferencing Imagery Discussion
- 611 GM Script Language
- 50 User Scripts
- 112 GPS Features
- 397 Projection Questions
- 805 Raster Data
- 1.3K Vector Data
- 6.5K Support
- 161 Announcement and News
- 893 Bug Report
- 557 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 546 Other Discussion
- 128 GIS Data Sources
- 26 Global Mapper Showcase
- 230 How I use Global Mapper
- 104 Global Mapper Forum Website