MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Problems after modifying a shape manually.

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 ...


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

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



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-15-2007
Member
Green Belt
 
Join Date: Nov 2006
Posts: 87
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!).
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 02-15-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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.
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 02-15-2007
Member
Green Belt
 
Join Date: Nov 2006
Posts: 87
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.
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 02-15-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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;
	}
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 02-15-2007
Member
Green Belt
 
Join Date: Nov 2006
Posts: 87
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 02-16-2007
Member
Green Belt
 
Join Date: Nov 2006
Posts: 87
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 02-16-2007
Member
Green Belt
 
Join Date: Nov 2006
Posts: 87
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 02-16-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 02-19-2007
Member
Green Belt
 
Join Date: Nov 2006
Posts: 87
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 02-19-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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.
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
manually, modifying, problems, shape


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


All times are GMT -5. The time now is 10:54 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