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搜索引擎的奥秘
- ››Google测试搜索结果页面右侧内容更丰富的信息栏
- ››调用已注册会员人数和最新会员名称
- ››Google Dart精粹:应用构建,快照和隔离体
- ››google的代码审查
- ››google analytics清晰追踪爬虫的爬行信息
- ››Google+中文用户在两千万Google+大军中是少数派
- ››Google AdWords最昂贵点击成本的20种关键词分类
- ››Google运作经理Bryan Power给出的GOOGLE求职意见
- ››Google用户体验的十大设计原则
- ››Google Analytics(分析)能为网站带来什么
- ››Google goggles图片搜索 如何优化一个wap网站
更多精彩
赞助商链接