📄 pan.cpp
字号:
#include "StdAfx.h"
#include ".\pan.h"
/////////////////////////////////////////////////////////////////////////////
// CPan
STDMETHODIMP CPan::OnMouseDown(LONG Button, LONG Shift, LONG X, LONG Y)
{
if (MouseDown(X,Y))
{
// Start the feedback
IScreenDisplayPtr cpScreenDisplay;
GetFocusMapScreenDisplay(&cpScreenDisplay);
IPointPtr cpPoint;
ToFocusMapPoint(X,Y, &cpPoint);
cpScreenDisplay->PanStart(cpPoint);
}
return S_OK;
}
STDMETHODIMP CPan::OnMouseMove(LONG Button, LONG Shift, LONG X, LONG Y)
{
if (CMapToolBase::IsMouseDown())
{
// Move the pan
IScreenDisplayPtr cpScreenDisplay;
GetFocusMapScreenDisplay(&cpScreenDisplay);
IPointPtr cpPoint;
ToFocusMapPoint(X,Y, &cpPoint);
cpScreenDisplay->PanMoveTo(cpPoint);
}
return S_OK;
}
STDMETHODIMP CPan::OnMouseUp(LONG Button, LONG Shift, LONG X, LONG Y)
{
if (CMapToolBase::IsMouseDown())
{
// Finish the Pan
IScreenDisplayPtr cpScreenDisplay;
IActiveViewPtr cpActiveView;
GetFocusMapActiveView(&cpActiveView);
cpActiveView->get_ScreenDisplay(&cpScreenDisplay);
IPointPtr cpPoint;
ToFocusMapPoint(X,Y, &cpPoint);
IEnvelopePtr cpNewEnvelope;
cpScreenDisplay->PanStop(&cpNewEnvelope);
// Update new maps extent
cpActiveView->put_Extent(cpNewEnvelope);
cpActiveView->Refresh();
}
// release mouse capture in base class
CMapToolBase::MouseUp();
return S_OK;
}
STDMETHODIMP CPan::OnKeyDown(LONG keyCode, LONG Shift)
{
if (keyCode == VK_ESCAPE)
{
// Abort the Pan as escape is pressed
IScreenDisplayPtr cpScreenDisplay;
IActiveViewPtr cpActiveView;
GetFocusMapActiveView(&cpActiveView);
cpActiveView->get_ScreenDisplay(&cpScreenDisplay);
IEnvelopePtr cpNewEnvelope;
cpScreenDisplay->PanStop(&cpNewEnvelope);
// Cause a repaint of the window to clear the pan effect
HWND hWnd;
m_hookHelper.get_hWnd(&hWnd);
::InvalidateRect(hWnd, 0, FALSE);
CMapToolBase::MouseUp();
}
return S_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -