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

How to make shapes unmoveable ?

This is a discussion on How to make shapes unmoveable ? within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, As shapes that are programmatically added can be moved by the user with the mouse, I wonder if it ...

  1. #1
    Jaba is offline Junior Member Yellow Belt
    Join Date
    Jan 2005
    Posts
    21

    How to make shapes unmoveable ?

    Hi, As shapes that are programmatically added can be moved by the user with the mouse, I wonder if it is possible to ice the shapes so that the user cannot move it ?

    Do you know if that is possible and how ? (without having to copy/paste the map on a picturebox )

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

    Yes it sure is possible. On this forum you find an article how to make pushpins inmoveable. Same trick could be used for shapes I suppose. http://www.mp2kmag.com/a97--pushpins....mappoint.html Check also what has been discussed here: http://www.mp2kmag.com/mappoint/disc...pic.asp?t=4315

  3. #3
    Jaba is offline Junior Member Yellow Belt
    Join Date
    Jan 2005
    Posts
    21
    Thanks. I've taken a look at these threads and they are interesting.

    In order to prevent the user from moving pushpins and shapes I've tried the following code but I alway get a "Stack Overflow" error from the C# runtime :

    Code:
    		private void axMappointControl1_SelectionChange(object sender, AxMapPoint._IMappointCtrlEvents_SelectionChangeEvent e)
    		{
    // I don't cast anything here because I consider any selection to be a shape or pushpin
    			MapPoint.Shape sp;
    			MapPoint.Location loc;
    			try
    			{
    				loc = axMappointControl1.ActiveMap.GetLocation(80,0,0);
    				sp = axMappointControl1.ActiveMap.Shapes.AddShape(MapPoint.GeoAutoShapeType.geoShapeRectangle,loc,1,1);
    				sp.Select();
    				sp.Delete();
    			}
    			catch(Exception)
    			{
    
    			}
    		}



    the error is :
    An unhandled exception of type 'System.StackOverflowException' occurred in axinterop.mappoint.dll

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

    Code:
    sp.Select();
    This is the quilty one When Select is called the while function will be re-entered, again and again until the stack flows over

    You have to set a busy flag on entering the function an first check if it is true, if true then exit. When the function exit you set the flag again to false.

    Do not put the flag on the stack.

    something like this will do:

    Code:
                if (!select_change_busy) {
                    select_change_busy = true;
                    // here the code
                    select_change_busy = false;
                }
    In the article it was with the mousebutton I think. But it is similar.

  5. #5
    Jaba is offline Junior Member Yellow Belt
    Join Date
    Jan 2005
    Posts
    21
    Great !!!! Thank you mister Wilfried !!!

    Let's share this wonderful tip :

    Code:
    		bool select_change_busy = false;
    		
    		private void axMappointControl1_SelectionChange(object sender, AxMapPoint._IMappointCtrlEvents_SelectionChangeEvent e)
    		{
    			if (!select_change_busy)
    			{
    				select_change_busy=true;
    				MapPoint.Shape sp;
    				MapPoint.Location loc;
    
    				try
    				{
    					loc = axMappointControl1.ActiveMap.GetLocation(80,0,0);
    					sp = axMappointControl1.ActiveMap.Shapes.AddShape(MapPoint.GeoAutoShapeType.geoShapeRectangle,loc,1,1);
    					sp.Select();
    					sp.Delete();
    				}
    				catch(Exception)
    				{
    
    				}
    
    				select_change_busy=false;
    			}
    		}

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

    Thanks for the feedback. Doing so other can benefit from it also

    Tip: You can put code between tags, then it is nice formatted and ident

  7. #7
    Jaba is offline Junior Member Yellow Belt
    Join Date
    Jan 2005
    Posts
    21
    Hi Wilfried...

    You're welcome

    Now I want to deactivate the moving of shapes only, because with the source code above this also deactivates the viewing of pushpins' labels

    I've tried the following to deactivate the moving of shapes only but I can't understand why it does not work as I would like it to ?

    Code:
    		bool select_change_busy = false;
    		private void axMappointControl1_SelectionChange(object sender, AxMapPoint._IMappointCtrlEvents_SelectionChangeEvent e)
    		{
    			if (!select_change_busy)
    			{
    				select_change_busy=true;
    				MapPoint.Shape sp;
    				MapPoint.Location loc;
    				MapPoint.Shape sp2;
    
    				try
    				{
    					sp2 = (MapPoint.Shape) e.pNewSelection;
    					loc = axMappointControl1.ActiveMap.GetLocation(80,0,0);
    					sp = axMappointControl1.ActiveMap.Shapes.AddShape(MapPoint.GeoAutoShapeType.geoShapeRectangle,loc,1,1);
    					sp.Select();
    					sp.Delete();
    					sp2=null;
    				}
    				catch(Exception)
    				{
    				}
    
    				select_change_busy=false;
    			}
    		}

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Make shorter a GeoBalloonState
    By clavijo in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-03-2004, 02:31 AM
  2. $$$ Will Pay for A Way to Make a Map $$$
    By webdbx in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 07-28-2004, 08:38 AM
  3. How to make invisible a pushpin
    By clavijo in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 07-09-2004, 07:41 AM
  4. Make New own baseMap
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-03-2003, 10:02 AM
  5. trying to make a 'locator map'
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-09-2003, 04:37 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 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