I'm trying to get the LAT/LON position of the mouse in a Windows Forms app using the browsercontrol and IGEPlugin. Anyone got a clue?
+1
A:
This isn't too hard if you use the free Winforms Geplugin control librar y- just follow these simple steps
You need to tell the web browser object that you want to listen for mousemove events
geWebBrowser.AddEventListener(gePlugin.getGlobe(), "mousemove");
Then you need setup some event handlers. The code below should be easy to read. You can determine the lat / long of the mouse cursor from the mouseEvent argument in the DoMouseMove method
geWebBrowser.KmlEvent += GeWebBrowserKmlEvent;
private void GeWebBrowserKmlEvent(object sender, GEEventArgs e)
{
// if it is a mouse event
if (null != sender as IKmlMouseEvent)
{
handleKmlMouseEvents((IKmlMouseEvent)sender, e.Data);
}
else
{
MessageBox.Show(GEHelpers.GetTypeFromRcw(sender));
}
}
private void handleKmlMouseEvents(IKmlMouseEvent mouseEvent, string action)
{
string currentTarget = mouseEvent.getCurrentTarget().getType();
switch (action)
{
case "mousemove":
{
DoMouseMove(mouseEvent);
break;
}
case "click":
{
DoClick(mouseEvent, currentTarget);
break;
}
case "mousedown":
{
DoMouseDown(mouseEvent, currentTarget);
break;
}
case "mouseup":
{
DoMouseUp(mouseEvent);
break;
}
}
}
private void DoMouseMove(IKmlMouseEvent mouseEvent)
{
}
Dominic
2010-07-14 15:54:21
link to the controls: http://code.google.com/p/winforms-geplugin-control-library/
Fraser
2010-07-16 15:28:46