MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




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 2006/2009 Discussion category; I am writing my code in C++ and at this point all I want to do is add a line ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion > Development

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (3) Thread Tools Display Modes
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-26-2007
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 11-26-2007
Winwaed's Avatar
Mapping-Tools.com
Red Belt
 
Join Date: Feb 2004
Posts: 901
Blog Entries: 10
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
Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 11-27-2007
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 11-27-2007
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 2,487
Blog Entries: 1
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
__________________
~ Now taking orders for MapPoint 2009 ~
~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 11-27-2007
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();
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
crashes, delete, shape, software


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/software-crashes-when-i-try-delete-shape-6793.html

Posted By For Type Date
The Magazine for MapPoint - MP2K Magazine This thread Refback 11-29-2007 10:17 AM
dahranis » software crashes when I try to delete a shape This thread Pingback 11-26-2007 01:23 PM
Apple Blog » Blog Archive » software crashes when I try to delete a shape This thread Pingback 11-26-2007 11:41 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
ERP Software - Looking For ERP Software Solution For Ladies Garment Manufacturer fashion4u News and Announcements 1 06-10-2008 10:19 AM
Does an object reside in my Shape or Shape boundaries? hotrdd MapPoint 2006/2009 Discussion 1 08-04-2005 10:51 PM
Consumers Trust Software Makers to Develop Car Software Eric Frost News and Announcements 0 04-17-2005 09:06 AM
Help crashes glshrike MapPoint 2006/2009 Discussion 1 02-03-2004 02:57 PM
Control Crashes - Help !!! dougw MapPoint 2006/2009 Discussion 1 04-10-2003 09:29 AM


All times are GMT -5. The time now is 07:16 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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