Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 4 of 4

C# ActiveX - Can't find user-drawn polygon shapes in Shapes collection?

This is a discussion on C# ActiveX - Can't find user-drawn polygon shapes in Shapes collection? within the Development forums, part of the MapPoint Desktop Discussion category; I am attempting to highlight all the pushpins in all the datasets after a user draws a polygon shape on ...

  1. #1
    citrix_99301's Avatar
    citrix_99301 is offline Junior Member Yellow Belt
    Join Date
    Mar 2006
    Posts
    15

    C# ActiveX - Can't find user-drawn polygon shapes in Shapes collection?

    I am attempting to highlight all the pushpins in all the datasets after a user draws a polygon shape on the MapPoint ActiveX object in a Windows Form (.NET Framework 4.0)

    oMap.Shapes.Count = 1 (according to my watch window), however oMap.Shapes[0] shows oMap.Shapes[0] throws an exception System.OutOfMemoryException' MapPoint.Shape {System.OutOfMemoryException}

    Am I missing something here?

    Thanks in advance for your time,

    Andre Ranieri

    Code:
            MapPoint.Shape objShape;
                    MapPoint.Map oMap = this.axMapPoint.ActiveMap;
                    foreach (MapPoint.DataSet oDS in oMap.DataSets)
                    {
                        if (oMap.Shapes.Count >= 1)
                        {
    
                            MapPoint.Recordset oRS = oDS.QueryShape(oMap.Shapes[0]);  Code Fails here
    
                            oRS.MoveFirst();
                            if (oRS.EOF)
                            {
                                continue;
                            }
    
                            oRS.MoveFirst();
                            if (oRS.EOF)
                            {
                                continue;
                            }
    
                            while (!oRS.EOF)
                            {
                                oRS.Pushpin.Highlight = true;
                            }
                        }
                    }
    Last edited by Eric Frost; 06-21-2012 at 10:04 AM.

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Posts
    1,766
    Blog Entries
    51

    Re: C# ActiveX - Can't find user-drawn polygon shapes in Shapes collection?

    Yes it fails because you can't index COM arrays like this in C#. If you want to work your way through the lot, then I would use foreach - like you are doing for the datasets.

    If you want to work with a specific index, you have to do it like this (note:1-referenced, NOT 0-referenced):

    Code:
                        object oidx = (object)1;
                        MapPoint.Shape oShp = oShapes.get_Item(ref oidx);
    Also be sure to check that oShp is valid for the QueryShape() method - it cannot be used with text boxes and 2-point lines.
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  3. #3
    citrix_99301's Avatar
    citrix_99301 is offline Junior Member Yellow Belt
    Join Date
    Mar 2006
    Posts
    15

    Re: C# ActiveX - Can't find user-drawn polygon shapes in Shapes collection?

    Thanks - I haven't developed in MapPoint in 3-4 years and had forgotten this.

    My shapes should all be polygons, squares and circles. Do I need some kind of validation to make sure that nothing else is selected?

    If the user creates several polygons, is there some mechanism by which I can iterate through the Shapes collection and determine which one is the selected one?

    Thanks,

    Andre

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Posts
    1,766
    Blog Entries
    51

    Re: C# ActiveX - Can't find user-drawn polygon shapes in Shapes collection?

    You need to look at the shape's ShapeType and AutoShapeType properties: Shape object
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Re-open Is user drawn freeform Poly Closed thread
    By tfmiltz in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 11-09-2007, 12:58 PM
  2. Tilted Shapes
    By whiskeyfur in forum Wish List
    Replies: 0
    Last Post: 11-01-2007, 12:52 PM
  3. Getting Records within Shapes
    By MagiCat in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-21-2007, 01:47 PM
  4. Naming Shapes
    By Daniel in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-19-2004, 04:49 AM
  5. Could someone explain how item() works on shapes collection?
    By spideybud in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 12-15-2003, 02:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24