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 5 of 5

software crashes when I try to delete a shape

This is a discussion on software crashes when I try to delete a shape within the Development forums, part of the MapPoint Desktop Discussion category; I am writing my code in C++ and at this point all I want to do is add a line ...

  1. #1
    leopoldB is offline Junior Member White Belt
    Join Date
    Nov 2007
    Posts
    5

    software crashes when I try to delete a shape

    I am writing my code in C++ and at this point all I want to do is add a line to the map and then be able to delete it. I can add the line just fine and I do it with the following code:

    void MapPt:: DrawLine(double Lat1, double Long1, double Lat2, double Long2)
    {
    //create a location object for each point
    WyptLocPtr1 = m_myMap->GetLocation( Lat1, Long1, 4 );
    locWypt1 = (Location*)WyptLocPtr1;
    WyptLocPtr2 = m_myMap->GetLocation( Lat2, Long2, 4 );
    locWypt2 = (Location*)WyptLocPtr2;

    //create a shapes object
    NavLinesPtr = m_myMap->GetShapes();
    NavLines = (Shapes*)NavLinesPtr;

    Shape* L;
    L = NavLines->AddLine(locWypt1,locWypt2);
    }

    After I have created this line on the map I cannot delete it though. To delete I just use the following code:

    Line->Delete()

    My software just crashes here, and the error I get is access violation. Any help here would be much appreciated.

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: software crashes when I try to delete a shape

    Sounds like your pointer is no longer valid.
    (I assume you meant "L" and not "Line"?)



    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  3. #3
    leopoldB is offline Junior Member White Belt
    Join Date
    Nov 2007
    Posts
    5

    Re: software crashes when I try to delete a shape

    I figured it out. I need two pointers to get it to work. I needed to first get a ShapePtr and then cast that to a Shape*. With this my code works.

  4. #4
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: software crashes when I try to delete a shape

    Can you post the new code for an example if others have the same problem?

    Thanks,
    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  5. #5
    leopoldB is offline Junior Member White Belt
    Join Date
    Nov 2007
    Posts
    5

    Re: software crashes when I try to delete a shape

    Here is my working code:

    void MapPt:: DrawLine(double Lat1, double Long1, double Lat2, double Long2)
    {

    //first must create a location object for each point
    WyptLocPtr1 = m_myMap->GetLocation( Lat1, Long1, 4 );
    locWypt1 = (Location*)WyptLocPtr1;
    WyptLocPtr2 = m_myMap->GetLocation( Lat2, Long2, 4 );
    locWypt2 = (Location*)WyptLocPtr2;

    //create a shape object
    NavLinesPtr = m_myMap->GetShapes();
    NavLines = (Shapes*)NavLinesPtr;

    //draw line
    LinePtr = NavLines->AddLine(locWypt1,locWypt2);
    Line = (Shape*)LinePtr;
    }

    To delete the line all I do is call:

    LinePtr->Delete();

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: 11-13-2013, 04:04 AM
  2. Does an object reside in my Shape or Shape boundaries?
    By hotrdd in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-04-2005, 10:51 PM
  3. Consumers Trust Software Makers to Develop Car Software
    By Eric Frost in forum News and Announcements
    Replies: 0
    Last Post: 04-17-2005, 09:06 AM
  4. Help crashes
    By glshrike in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-03-2004, 02:57 PM
  5. Control Crashes - Help !!!
    By dougw in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-10-2003, 09:29 AM

Tags for this Thread

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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96