开发学院软件开发C语言 C# 调用 Google Earth Com API开发(三) 阅读

C# 调用 Google Earth Com API开发(三)

 2009-05-22 08:29:45 来源:WEB开发网   
核心提示: 2、鼠标消息此例子中对于鼠标消息到处理使用了钩子,调用HookAPI.dll实现,C# 调用 Google Earth Com API开发(三)(2),1:///<summary>2:///鼠标钩子3:///</summary>4:privateMouseHookm

2、鼠标消息

此例子中对于鼠标消息到处理使用了钩子,调用HookAPI.dll实现。

  1:     /// <summary>
  2:     /// 鼠标钩子
  3:     /// </summary>
  4:     private MouseHook mouseHook;
  5:  
  6:     // 设置鼠标钩子
  7:     mouseHook = new MouseHook();
  8:     mouseHook.MouseClick += new MouseEventHandler(mouseHook_MouseClick);
  9:     mouseHook.MouseDbClick += new MouseEventHandler(mouseHook_MouseDbClick);
 10:     mouseHook.MouseWheel += new MouseEventHandler(mouseHook_MouseWheel);
 11:     // 启动鼠标钩子
 12:     mouseHook.StartHook(HookType.WH_MOUSE_LL, 0);

单击事件:

  1: /// <summary>
  2: /// 鼠标钩子。鼠标单击事件
  3: /// </summary>
  4: /// <param name="sender"></param>
  5: /// <param name="e"></param>
  6: void mouseHook_MouseClick(object sender, MouseEventArgs e)
  7: {
  8:   IntPtr hWnd = NativeMethods.WindowFromPoint(e.Location);
  9:   if (hWnd == this.GeRenderHWnd)
 10:   {
 11:     Point point = this.Control.PointToClient(e.Location);
 12:     // 如果鼠标击点位置在控件内部,则说明鼠标点击了GoogleEarth视图
 13:     if (this.Control.ClientRectangle.Contains(point))
 14:     {
 15:       Console.WriteLine("点击了GoogleEarth...");
 16:  
 17:       DoublePoint dp = ((GERenderPanel)Control).DetermineScreenCoordinates(point.X, point.Y);
 18:  
 19:       ParameterizedThreadStart pts = new ParameterizedThreadStart(ShowMouseClickPoint);
 20:  
 21:       Thread thread = new Thread(pts);
 22:       thread.Start(dp);
 23:  
 24:     }
 25:   }
 26: }
 27:  
 28: protected void ShowMouseClickPoint(object obj)
 29: {
 30:   //Thread.Sleep(20);
 31:   DoublePoint dp = (DoublePoint)obj;
 32:   PointOnTerrainGE pGe = GeApp.GetPointOnTerrainFromScreenCoords(dp.X, dp.Y);
 33:   Console.WriteLine("鼠标点击了:Lnt=" + pGe.Longitude.ToString() 
 34:     + ";Lat=" + pGe.Latitude.ToString());
 35: }

上一页  1 2 3 4  下一页

Tags:调用 Google Earth

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接