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
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Problems after modifying a shape manually.

This is a discussion on Problems after modifying a shape manually. within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello guys, When I create a shape object programmatically and than change its size manually, mappoint crashes when I try ...

  1. #1
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Problems after modifying a shape manually.

    Hello guys,

    When I create a shape object programmatically and than change its size manually, mappoint crashes when I try to retrieve the shape object programmatically again. So what happens with the shape object if I change its propperties manually? It looks like that mappoint changes the whole object and places at another memory address. Cause I get the message that I'm trying to overwrite in a memory part which doesn't belong to me and thus forbidden (boom!).

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

    Re: Problems after modifying a shape manually.

    Hi,

    No this should be possible. I can create a shape in code, then user can move / resize it, and the object in the code remains valid, because I can delete it then in code.

    Of course you have to check if the object is still existing if you let the user delete it for example.

    Another approach is to give each shape an exclusive name, so you can search for the name when you need it again.

  3. #3
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Problems after modifying a shape manually.

    Hi Wilfried,

    Thank you for you reply,
    Well it is really strange though, even when I just select the shape I can't get it back programmatically. If I don't "touch" it at all, than I can get the object back.

    A mappoint object (like a shape) is really deleted if I call the delete() method right? It's a bit confusing.

    By the way Wilfried, how can I get (find) the shape by name? Because I give each shape a "unique" name. I don't know which method I need to call.
    Thank you.

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

    Re: Problems after modifying a shape manually.

    Hi,

    I just did following test:

    Code:
    private Shape myShape;
    private void tEstToolStripMenuItem1_Click_1(object sender, EventArgs e)
    {
        Location loc = MP.ActiveMap.GetLocation(51, 4, 1);
        myShape = MP.ActiveMap.Shapes.AddShape(GeoAutoShapeType.geoShapeRectangle, loc, 10, 10);
        myShape.Select();
        myShape.Name = "Wilfried";
    }
    
    private void test2ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        myShape.Delete();
    }
    I hit the first menu item. Shape is created. Then I resize it and move it somwhere else and the second menu item it is deleted. So there must be something else wrong.

    To find a shape by name you can use following code extract:

    Code:
        foreach (Shape s in MP.ActiveMap.Shapes)
    	if (s.Name == "Wilfried") {
    	    s.Delete();
    	    break;
    	}

  5. #5
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Problems after modifying a shape manually.

    Hi Wilfried,

    You are very right.
    The problem now, is when I select a a shape my eventhandler treats the shape object as a pushpin and than it collapses. Now I have the problem to figure out what type the selected object in. I guess in C# it is made easy, but in VC++ it is a bit difficult to retrieve the type of object. I hope somebody else know how to do that, because I think I have to dive in COM and I'm not that good in COM.


    So it's a bit tricky, I really hope somebody knows COM well.

  6. #6
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Problems after modifying a shape manually.

    Hello guys,

    I still get stuck with that shape thing. If I delete the the shape doing as follow: select shape on map by mouse, than press delete-key.
    I don't get any notification from Mappoint, I analysed that with Spy++ tool. I see the delete-key message and others like paint message etc.. But after delete-key message I don't see any message following which notifies that it redraws or something. So I'm afraid that AfterRedraw event won't notify either.

    The problem is that I keep a list of objects, but Mappoint doesn't notify me wether an object is deleted or not, for me it's a major disadvantage.

    This is also for pushpins and I guess other objects.

  7. #7
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Problems after modifying a shape manually.

    VC++ 6.0
    Mappoint 2006

    Unfortunatly I can't get help about my previous post, so I try it from another approach. How can I DESELECT a pushpin or shape etc...?


    Thank you.

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

    Re: Problems after modifying a shape manually.

    Hi,

    No you dont get events. You can do a lot of things like prevent the user to hit the delete key. Therefore you can set the form's keypreview to true, but there is still the 'delete' item in the popup menu. Therefore you can display your own popup menu.

    But the most easy one is to prevent that a user can select something. Or you can choose what he cannot select. You can do this in SelectionChange event. There you check what is selected, do somewhat in the sea (eg put a puschpin), select() it and delete it. Then the selected item is unselected.

  9. #9
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Problems after modifying a shape manually.

    Hi Wilfried,

    That's what I thought also, but the problem with shape is that I want the user to be able to change the shape's size and its shape by moving his/her mouse. So I have to enable the selection option. If a pushpin is moved by the user than it doesn't matter to me, because the info about the pushpin is saved in the text field of the pushpin.

    The best solution I also thought of, is to disable the delete-key, but I don't know how to do that in VC++. Cause Mappoint runs in an apart process and at the moment I don't know how to disable the delete-key.
    So I've to figure out how to do that.

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

    Re: Problems after modifying a shape manually.

    Hi,

    I dont know how to do that exact in VC++, but for example in Delphi I can associate Mappoint in an OLE container and this one can on a form. Then it works with the KeyPreview. I assume something similar is possible in VC++.

    I just see that there is in mappoint also a PreviewKey event.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. pushpins in manually drawn shape
    By chupax in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-02-2006, 02:34 PM
  2. Assign Pushpins Manually
    By jempie in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 10-31-2006, 12:00 PM
  3. Modifying the Label in MapPoint
    By sparky in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 05-17-2006, 07:11 AM
  4. Modifying pushpins??
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-09-2004, 02:56 PM
  5. How can I manually put in pushpins for address tha....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-27-2001, 07:10 PM

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