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

Deleting all CShape in CShapes

This is a discussion on Deleting all CShape in CShapes within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, I have a member variable CShapes m_carPath for which I do AddLine( oldlocation, newlocation ) each time I update ...

  1. #1
    discostu is offline Junior Member White Belt
    Join Date
    May 2005
    Posts
    9

    Deleting all CShape in CShapes

    Hi, I have a member variable CShapes m_carPath for which I do AddLine( oldlocation, newlocation ) each time I update the car's position (represented by a pushpin). I have a reset button in this MFC app that when pressed deletes the pushpin representing the car and also attempts to delete all the lines associated with m_carPath (these are of type CShape). My code below seems to only delete every other line:
    Code:
    	VARIANT idx;
    	VariantInit( &idx );
    	V_VT(&idx) = VT_I4;
    	for&#40; long i = 1; i <= m_carPath.GetCount&#40;&#41;; i++ &#41; &#123;
    		V_I4&#40;&idx&#41; = i;
    		CShape shape = m_carPath.GetItem&#40; &idx &#41;;
    		shape.Delete&#40;&#41;;
    	&#125;
    If I hit "Reset" over and over, more and more lines go away.
    Any idea why? Please help. Thanks! -Stu

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I dont understeand the question very whell but is it not more easy to just move the pushpin to the new position and eventually change balloon information ?

  3. #3
    discostu is offline Junior Member White Belt
    Join Date
    May 2005
    Posts
    9
    Ok, my question was not about the pushpin. It was about a line that I am drawing to trail the pushpin. But your answer posts another question for me. So, I'm going to try and make it clear with two questions.

    1. How do you just move a pushpin in c++? I read on the forums that you have to delete it everytime and make a new one at the new location.
    2. My original question: Why does my code not delete all CShape instances in CShapes. In my OnTimer() function I "move" the pushpin (by deleting it, and making a new one -- see question 1). In the same OnTimer() function I also do AddLine(oldLocation, newLocation) to my CShapes instance. When I try to delete all these lines in CShapes instance. Only some, get deleted (it looks to be every other one).


    If this is not clear let me know.
    Thanks!
    Stu

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Now I understeand

    This example try to find a pushpin on the map, create a new if not found, and move the existing with the same name if found:

    Code:
            private Pushpin MovePP&#40;string name, double lat, double lon&#41;
            &#123;
                Location Loc = MP.ActiveMap.GetLocation&#40;lat, lon, 1&#41;;
                Pushpin PP = MP.ActiveMap.FindPushpin&#40;name&#41;;
                if &#40;PP == null&#41;
                    PP = MP.ActiveMap.AddPushpin&#40;Loc, name&#41;;
                PP.Location = Loc;
                PP.GoTo&#40;&#41;;
                return PP;
            &#125;
    As for your code, it will delet every other one because you delete very other one because of the index (i).. If you change it with a while loop it will work. Now you delete, then the index is removed, count is decrement, you increment index and delete 1 step higher. Common mistakes we all do once a while

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Deleting pushpins in bulk
    By brianmcg in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-22-2006, 02:08 PM
  2. Selecting and deleting the push pin
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-10-2005, 08:01 AM
  3. deleting city names
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-04-2004, 07:53 PM
  4. New map (Deleting)
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-21-2004, 04:21 AM
  5. disabling deleting pushpin
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-28-2004, 09:14 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