Community of VE/MapPoint Users and Developers
This is a discussion on Problems after modifying a shape manually. within the MapPoint 2006/2009 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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Problems after modifying a shape manually. 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!). |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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. |
| |||
| 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();
}
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;
}
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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. |
| |||
| 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. |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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. |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| manually, modifying, problems, shape |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pushpins in manually drawn shape | chupax | MapPoint 2006/2009 Discussion | 1 | 12-02-2006 02:34 PM |
| Assign Pushpins Manually | jempie | MapPoint 2006/2009 Discussion | 2 | 10-31-2006 12:00 PM |
| Modifying the Label in MapPoint | sparky | MapPoint 2006/2009 Discussion | 2 | 05-17-2006 07:11 AM |
| Modifying pushpins?? | Anonymous | MapPoint 2006/2009 Discussion | 1 | 12-09-2004 02:56 PM |
| How can I manually put in pushpins for address tha.... | Anonymous | MapPoint 2006/2009 Discussion | 1 | 06-27-2001 07:10 PM |