Still stuck on the freeform event!

mmartin
04-16-2007, 02:45 PM
Hello people,

Can anyone say why I always get type 1 returned with in this doubleclick event...I am trying to draw a freeform on the map and then catch it as
such with the event...the type should be 5 (freeform)..but is always 1

thanks..

PrivateSub AxMappointControl1_BeforeDblClick1(ByVal sender AsObject, ByVal e As AxMapPoint._IMappointCtrlEvents_BeforeDblClickEven t) Handles AxMappointControl1.BeforeDblClick
Dim omap As MapPoint.Map
omap = AxMappointControl1.ActiveMap
MsgBox("The type of this shape is: " _
+ CStr(omap.Shapes.Item(1).Type))
If omap.Selection IsNothingThen
Stop
EndIf
EndSub

Wilfried
04-17-2007, 06:08 AM
Hi,

Please do not double post. If you think your original post is not seen then you can reply to it and it will move back to top and will be set not read.

Are you sure there is not another shape on your map ?

mmartin
04-17-2007, 05:09 PM
Thanks Wilfried... I am working with a new clean map with no other shapes. I have the same difficulty with the following code, that is, when doubleclicking on a shape on the map the code fires, but never finds a shape object..thanks for any help.

Private Sub AxMappointControl1_BeforeDblClick(ByVal sender As Object, ByVal e As AxMapPoint._IMappointCtrlEvents_BeforeDblClickEven t) Handles AxMappointControl1.BeforeDblClick

Dim searche As MapPoint.FindResults = AxMappointControl1.ActiveMap.ObjectsFromPoint(e.x, e.y)

For Each result As Object In searche
If TypeOf result Is MapPoint.geoshapetype Then
.....never gets here
End If
Next

End Sub

Wilfried
04-18-2007, 02:10 AM
Hi,

That is correct. You click on the Shape but not on the Location where the Shape is (probably the center).

If you want a user to do something when clicking on a Shape use SelectionChange event. Eventually you can check if it is what you want and popup a menu at mouse position.

As for your first question I did a similar test in the SelectionChange event handler, drawing a free form and then select it:

Console.WriteLine("selection change");
Shape s = map.Selection as Shape;
if (s != null)
Console.WriteLine(s.Type);

And it displays: "GeoFreeForm" so this looks ok to me.

mmartin
04-18-2007, 08:30 AM
Wilfried, thanks...!

I got it working, based on your explination and code example I tried it again and it was good. I used the VB below. Thanks again. Michael

Dim objmap As MapPoint.Map
objmap = AxMappointControl1.ActiveMap
Dim shape As MapPoint.Shape = objmap.Shapes.Item(1)
If shape Is Nothing Then
MsgBox("no shape")
Else
MsgBox("type" & shape.Type)
End If

 
Web mp2kmag.com
mapforums.com