Global Mapper Pro Coming Soon

fill color to area

kokokoko Global Mapper UserPosts: 3
edited July 2009 in SDK
Help me please,

i use Visual C# (VS2008) Sample Application , load shape file it have 2000 areas and i want to fill color some area but it can't.

this is my code

private void FillColor()
// theAreaStyle is global variable, i set value to it on load layer.
theAreaStyle.mBrushColor = ColorToUInt(Color.Red);

for (UInt32 i = 0; i <= 500; i++)
LastGMError = GlobalMapperDLL.GM_SetAreaFeatureDrawStyle(clsGlobalVARS.LayerHandles[0], i, ref theAreaStyle);
private uint ColorToUInt(Color color)
return (uint)((color.A << 24) | (color.R << 16) |
(color.G << 8) | (color.B << 0));
public static extern GM_Error_t32 GM_SetAreaFeatureDrawStyle
IntPtr aLayer, // Layer the area is in
UInt32 aAreaIndex, // Index of area in layer
ref GM_AreaStyle_t aAreaStyle // New style to use for area

when i call FillColor function
LastGMError = GM_Error_None alway but area don't fill color.


  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited July 2009
    What do the other members of your global variable 'theAreaStyle' look like? You are just setting the color, but you will also need to set the fill style, etc. otherwise the fill color might not even be used.


    Global Mapper Support
  • kokokoko Global Mapper User Posts: 3
    edited July 2009
    i set theAreaStyle :

    theAreaStyle.mBorderPenStyle = 0;
    theAreaStyle.mBorderPenWidth = 1;
    theAreaStyle.mBorderPenColor = 0;
    theAreaStyle.mBrushColor = 2164195328;
    theAreaStyle.mBrushStyle = GM_BrushStyle_t16.GM_BRUSH_SOLID;
    theAreaStyle.mDrawLabel = 1;
    theAreaStyle.mDrawLabelAlways = 0;

    it can work with C++ Sample Application but Visual C# (VS2008) Sample Application can't work. I must update about DrawLayersToBitmap() Function Right?
  • OseiOsei Global Mapper User Posts: 119Trusted User
    edited July 2009
    A quick look suggests everything is ok. I am trying to identify the problem.
    I suggest you use the ColorTranslator class rather than bit shifting.

    In your GM_AreaStyle_t structure, make sure the size of the structure is correct. You can check the size of the same structure in the C++ sample by getting the value of

    The size being reported must be the same as

    If the two are not the same, then you have to fix that ASAP as it can lead to memory issues that can affect the entire program later.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited July 2009
    I'm not sure what your DrawLayersToBitmap function does, but typically after making changes to the display characteristics you would call Invalidate to cause your window to redraw.

    If you can post your GM_AreaStyle_t declaration we can check that as well. Osei's recommendation to check the sizes between C++ and C# is good to help verify your declaration is correct.


    Global Mapper Support
  • kokokoko Global Mapper User Posts: 3
    edited July 2009
    thank you very much Osei , Mike :

    I check my GM_AreaStyle_t declaration and try it then it can work.
Sign In or Register to comment.