(VB. NET source code)
Because scenecontrol does not respond to scroll wheel sliding events, you must first write a scroll wheel sliding event.
Axscenecontrolpolicwheel
Then, when loading, add the scroll wheel sliding handle
Addhandler me. mousewheel, addressof axscenecontrol?wheel
In this way, the scroll wheel is moved to the axscenecontrolpolicwheel.
Then write the operation statement in axscenecontrolpolicwheel.
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
In this way, you can smoothly respond to the zoom-in and zoom-out of the scroll wheel sliding. Map and globe can also be implemented in this way. Other controls that do not support the scroll wheel event can also be implemented in this way.