How to change line style

jharding@mtaonline.netjharding@mtaonline.net Global Mapper UserPosts: 7
edited February 2014 in SDK
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);

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited February 2014
    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
  • jharding@mtaonline.netjharding@mtaonline.net Global Mapper User Posts: 7
    edited February 2014
    Thanks Mike, that worked.
Sign In or Register to comment.