C# 调用 Google Earth Com API开发(三)
2009-05-22 08:29:45 来源:WEB开发网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: }
- ››Google运作经理Bryan Power给出的GOOGLE求职意见
- ››Google用户体验的十大设计原则
- ››Google Analytics(分析)能为网站带来什么
- ››Google goggles图片搜索 如何优化一个wap网站
- ››Google Docs将增加iPhone和Android编辑功能
- ››Google Android操作系统内核编译图文教程
- ››google map api 与jquery结合使用--控件,监听器...
- ››google map api 与jquery结合使用(2) --标注,浮...
- ››google map api 与jquery结合使用(3) --图标样式...
- ››Google 首页代码分析及简评
- ››Google财经更新iPhone和Android版本
- ››Google否认Android应用认证体系被破解
更多精彩
赞助商链接