Community of VE/MapPoint Users and Developers
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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Locating the name of a Shape selected 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 |
| ||||
|
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 |
| |||
|
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 |
| |||
|
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 |
| |||
|
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;
Regards Les |
![]() |
| Tags |
| locating, selected, shape |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 10:51 PM |
| Newbie Question: Locating golf courses around pushpins? | Anonymous | MapPoint 2006/2009 Discussion | 2 | 06-07-2004 09:27 AM |
| Locating pushpins w/in specific distance | Anonymous | MapPoint 2006/2009 Discussion | 0 | 12-19-2003 06:07 PM |
| Pl.. Help ----Locating/ placing positions in India | Anonymous | MapPoint 2006/2009 Discussion | 0 | 11-13-2003 03:20 AM |
| Locating pushpin with partial name | Dazzer | MapPoint 2006/2009 Discussion | 5 | 10-27-2003 06:01 AM |