【解决办法】:
1,禁用IMapControl的默认鼠标滚轮事件。
即设置IMapControl4.AutoMouseWheel= false;
2,重写鼠标滚轮事件。
比如在Form1_Load函数中加上this.MouseWheel += new System.Windows.Forms.MouseEventHandler(axMapControl1_OnMouseWheel);
然后重写private void axMapControl1_OnMouseWheel(object sender, MouseEventArgs e)函数,函数中内容即为鼠标滚轮缩放的代码实现。比如:
using ESRI.ArcGIS.Geometry;
private void Form1_Load(object sender, EventArgs e)
{
axMapControl1.AutoMouseWheel = false; //禁止axMapControl使用滚轮
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(axMapControl1_OnMouseWheel); //加载鼠标滚轮缩放事件
}
/// 重写鼠标滚轮缩放事件,前滚放大,后滚缩小
private void axMapControl1_OnMouseWheel(object sender, MouseEventArgs e)
{
IEnvelope mEnvelope = null;
IPoint mPoint = new PointClass();//缩放中心点
IPoint mousePoint = null;//鼠标点击点
try
{
mEnvelope = axMapControl1.ActiveView.Extent;
mPoint.X = (mEnvelope.XMax + mEnvelope.XMin) / 2;
mPoint.Y = (mEnvelope.YMax + mEnvelope.YMin) / 2;
mousePoint = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.X, e.Y);
double moveDisX = mousePoint.X - (mEnvelope.XMax + mEnvelope.XMin) / 2;
double moveDisY = mousePoint.Y - (mEnvelope.YMax + mEnvelope.YMin) / 2;
mEnvelope.CenterAt(mousePoint);
if (e.Delta > 0)
{
mEnvelope.Width = mEnvelope.Width * 0.8;
mEnvelope.Height = mEnvelope.Height * 0.8;
mPoint.X = mousePoint.X - moveDisX * 0.8;
mPoint.Y = mousePoint.Y - moveDisY * 0.8;
}
else if (e.Delta < 0)
{
mEnvelope.Width = mEnvelope.Width * 1.25;
mEnvelope.Height = mEnvelope.Height * 1.25;
mPoint.X = mousePoint.X - moveDisX * 1.25;
mPoint.Y = mousePoint.Y - moveDisY * 1.25;
}
mEnvelope.CenterAt(mPoint);
axMapControl1.ActiveView.Extent = mEnvelope;
axMapControl1.ActiveView.Refresh();
}
catch
{
}
}
通过以上两步即完成了Engine中鼠标滚轮缩放反置的功能。