posts - 35,  comments - 18,  trackbacks - 0

(VB.Net源码)
由于Scenecontrol中没有响应滚轮滑动的事件,所以首先得写一个滚轮滑动事件

AxSceneControl1_Wheel

然后,在Load时,添加鼠标滚轮滑动句柄

AddHandler Me.MouseWheel, AddressOf AxSceneControl1_Wheel

这样就将鼠标滚轮滑动与AxSceneControl1_Wheel挂接起来了

然后在AxSceneControl1_Wheel中写入操作语句

    Try
      Dim pSceLoc As System.Drawing.Point = AxSceneControl1.PointToScreen(Me.AxSceneControl1.Location)
      Dim Pt As System.Drawing.Point = Me.PointToScreen(e.Location)
      If Pt.X < pSceLoc.X Or Pt.X > pSceLoc.X + AxSceneControl1.Width Or Pt.Y < pSceLoc.Y Or Pt.Y > pSceLoc.Y + AxSceneControl1.Height Then Exit Sub
      Dim scale As Double = 0.2
      If e.Delta < 0 Then scale = -0.2
      Dim pCamera As ICamera = AxSceneControl1.Camera
      Dim pPtObs As IPoint = pCamera.Observer
      Dim pPtTar As IPoint = pCamera.Target
      pPtObs.X += (pPtObs.X - pPtTar.X) * scale
      pPtObs.Y += (pPtObs.Y - pPtTar.Y) * scale
      pPtObs.Z += (pPtObs.Z - pPtTar.Z) * scale
      pCamera.Observer = pPtObs
      AxSceneControl1.SceneGraph.RefreshViewers()
    Catch ex As Exception
    End Try

这样就可以顺利响应鼠标滚轮滑动的放大与缩小了,Map、Globe中也可以如此实现,其它不支持鼠标滚轮事件的控件也可以这样做

posted on 2008-05-13 08:15 王者之魂 阅读(173) 评论(1)  编辑 收藏

FeedBack:
2008-07-03 21:07 | 淡淡的 [未注册用户]
谢谢提供,很是有用
  回复  引用  查看    

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-05-28 14:45 编辑过
 
另存  打印
最新IT新闻:
 

众 万
志 众
成 一
城 心

诚 心
祝 愿
中 震
国 区
人 百
民 姓
幸 安
福 康

寻找兼职!QQ:13945133
MSN:yangguanjunmeteor@hotmail.com


<2008年5月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

与我联系

常用链接

留言簿(1)

我参与的团队

我的标签

随笔档案(35)

友情链接

搜索

  •  

最新评论

阅读排行榜

评论排行榜

60天内阅读排行