MapPoint Forums

MapForums

Community of MapPoint and Virtual Earth Users and Developers




Locating the name of a Shape selected

This is a discussion on Locating the name of a Shape selected within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hello I'm trying to find the name of a shape by clicking on it. I've succesfully created an event when ...


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

Today's Posts Twitter Feed 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 04-29-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Locating the name of a Shape selected

Hello

I'm trying to find the name of a shape by clicking on it.

I've succesfully created an event when the mouse pointer is on the shape by using the "SelectionChange" event, but how do I find the name of the shape I've just selected, so it's ready to place into a string variable.

The code I used to select the shape is shown below: -

procedure TMainForm.MappointSelectionChange(Sender: TObject; const pNewSelection, pOldSelection: IDispatch);
var
oShape: Shape;
begin
If assigned(pNewSelection) Then
Begin
pNewSelection.QueryInterface(IID_Shape, oShape);
If assigned(oShape) Then
Begin
Showmessage('Its a Shape');
// Now I need the name of the shape !!!!!!
End;
End;
end;

Note, I'm not using a commercial database, and have not imported data, I'm using my own comma delimited data to add the shapes.

Each shape has a name representing its place in the database. i.e. a number converted into a string.

I'm using Delphi but do understand VB (slightly), so any help in either language would be of great benefit.

Thank you

Regards
Les
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 04-29-2004
John Meyer's Avatar
Senior Member
Blue Belt
 
Join Date: Jul 2002
Posts: 479
Here is a vb example, hope it helps you...

Code:
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objLoc As MapPoint.Location
Dim objShape As MapPoint.Shape
  'Set up application and get a location object
Set objMap = objApp.ActiveMap
objApp.Visible = True
objApp.UserControl = True
  Set objLoc = objApp.ActiveMap.GetLocation(0, 0)

'Create a shape at this location, zoom to this location
Set objMap.Location = objLoc
Set objShape = objMap.Shapes.AddShape(geoShapeRectangle, objLoc, 50, 30)
objShape.Name = "Test123"
MsgBox objShape.Name
__________________
John
http://www.support-pc.com

Order MapPoint 2006 Here
https://secure.mp2kmag.com/?refer=support-PC
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 04-30-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Thanks for the code John, but I'm not sure it does the required task.

Looking at the code, it seems to be simply placing a shape and displaying it's name.

I may be wrong on this, as I find VB syntax very confusing. The part I'm not sure about is the fist block of code: -

'Set up application and get a location object
Set objMap = objApp.ActiveMap
objApp.Visible = True
objApp.UserControl = True
Set objLoc = objApp.ActiveMap.GetLocation(0, 0)

What exactly is this doing?

Thank you

Regards
Les
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 04-30-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Examining the code more closely, it does seem as though it is simply finding a location at coord 0,0, then placing an object, then retreiving it's name.

What i'm trying to accomplish (with very little headway) is the name of a shape previously placed on the map, simply by selecting it with the mouse pointer.

Selecting the shape and recognising it is a shape was relatively straightforward, but I simply cannot find anything in the help or the MSDN that is of any relevance to a shape. Pushpin yes, shape No!

Regards
Les
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 04-30-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
Hello John

You know when you can't see the wood for the trees, well I've just had that experience.

You're code pushed me in the right direction.

I now realise that selecting a shape using the mouse pointer is exacly the same as issuing the .SELECT command. So once it's selected, the .NAME command can be issued. It's so simple once the penny drops.

So for anyone out there using Delphi and wanting to find the name of a shape when selecting with a mouse, here's a procedure that will accomplish it.

Code:
procedure TMainForm.MappointSelectionChange(Sender: TObject; const pNewSelection, pOldSelection: IDispatch); 
var 
    oShape: Shape; 
begin 
    If assigned(pNewSelection) Then 
      Begin 
        pNewSelection.QueryInterface(IID_Shape, oShape); 
        If assigned(oShape) Then Showmessage('Shape Name = ' + oShape.Name); 
      End; 
end;
Thanks ever so much for the push in the right direction.

Regards
Les
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
locating, selected, 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
Does an object reside in my Shape or Shape boundaries? hotrdd MapPoint 2006/2009 Discussion 1 08-04-2005 09:51 PM
Newbie Question: Locating golf courses around pushpins? Anonymous MapPoint 2006/2009 Discussion 2 06-07-2004 08:27 AM
Locating pushpins w/in specific distance Anonymous MapPoint 2006/2009 Discussion 0 12-19-2003 05:07 PM
Pl.. Help ----Locating/ placing positions in India Anonymous MapPoint 2006/2009 Discussion 0 11-13-2003 02:20 AM
Locating pushpin with partial name Dazzer MapPoint 2006/2009 Discussion 5 10-27-2003 05:01 AM


All times are GMT -5. The time now is 11:21 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 RC2
MP2K Magazine
Visitor Map

Majorca Holiday
Enjoy a Majorca holiday at a good price when you check out the offers on UlookUbook for this popular destination!



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