Anonymous
04-05-2002, 10:48 PM
This article explains how to use VB.NET to create an improved location sensor for MapPoint. DnClipPos can copy the current lat/lon to the clipboard, and supports configurable display formats.
Read the full article: http://www.mp2kmag.com/articles.asp?ArticleID=66
gkirbo
02-21-2006, 09:42 AM
I'm trying to make your code work in Visual Basic Express 2005 and i'm having trouble with the Event Handlers in DnClipPos... to simplify matters i took problem snippets from DnClipPos and moved them to an independent form (i describe this in the next paragraph). The error i keep getting no matter how i try relates to the three event handlers in DnClipPos (and short snippet test)... i tried using the automatic event code generator by going out to the form design tab and selecting my AxMapPoint control and then going to properties and double clicking on the BeforeClick event handler... which automatically generates an event handler in the Form1 code... however this event handler doesn't capture the mouse location with the X and Y variables... when i try to change the code to resemble yours i get errors and when i use the MapPoint 2004 HELP example of how to handle the BeforeMouse click event it doesn't work either. I'm not very good with OOP and so i think my errors may be a simple structural issue... but i'm stumped. Can you help?
I have a form with a Command Button on it and a MapPoint DotCom Component Map Placed on the form… named AxMappointControl1. I’m trying to capture the screen coordinates of the mouse pointer over the mappoint map. I get a build Error with the word “BeforeClick” underlined in my code.
The ERROR message is as follows:
Error 1 Event 'BeforeClick' cannot be found.
Help says the Error Code is BC30590
MY CODE IS AS FOLLOWS:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.AxMappointControl1.OpenMap("C:\maps\BAD.ptm")
Dim WithEvents oMap As MapPoint.Map = Me.AxMappointControl1.ActiveMap
End Sub
Private Sub OnClick(ByVal Button As Integer, ByVal Shift As Integer,
ByVal X As Integer, ByVal Y As Integer, ByRef Cancel As Boolean) Handles
oMap.BeforeClick
Dim oResults As MapPoint.FindResults
Cancel = True ' Do not perform the usual action on click
Dim oLoc As MapPoint.Location
Set oLoc = oMap.XYToLocation(X, Y)
If Not (oLoc Is Nothing) Then oLoc.GoTo
End Sub
End Class
I HAVE MADE THIS CODE WORK..
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.AxMappointControl1.OpenMap("C:\maps\BAD.ptm")
Dim map As MapPoint.Map = Me.AxMappointControl1.ActiveMap
End Sub
Private Sub AxMappointControl1_BeforeClick(ByVal sender As
System.Object, ByVal e As AxMapPoint._IMappointCtrlEvents_BeforeClickEvent)
Handles AxMappointControl1.BeforeClick
MsgBox("This Works")
End Sub
End Class
Can someone help me with the event error?