在基于 mfc 对话框中,CDispView 是从 CScrollView 驱动的。左键单击时需要放大到某个点,右键单击时需要缩小。以下部分工作。有什么办法让它更好地工作吗?相应地调整滚动条的大小,放大一点等。
xzfac = 1;
yzfac = 1;
void CDispView::OnInitialUpdate()
{
SetScrollSizes(MM_TEXT, CSize(cWidth, cHeight));
CScrollView::OnInitialUpdate();
}
void CDispView::OnDraw(CDC* pDC)
{
StretchDIBits(pDC->GetSafeHdc(), 0, 0,
(xzfac * pBmpInfo->bmiHeader.biWidth),
(yzfac * pBmpInfo->bmiHeader.biHeight),
0, 0, pBmpInfo->bmiHeader.biWidth,
pBmpInfo->bmiHeader.biHeight,
imageBuf, pBmpInfo, DIB_RGB_COLORS,
SRCCOPY);
}
void CDispView::refresh()
{
OnInitialUpdate();
}
void CDispView::OnLButtonDown(UINT nFlags, CPoint point)
{
yzfac = yzfac + 1;
xzfac = xzfac + 1;
refresh();
RedrawWindow();
CScrollView::OnLButtonDown(nFlags, point);
}
void CDispView::OnRButtonDown(UINT nFlags, CPoint point)
{
yzfac = yzfac - 1;
if (yzfac < 1) yzfac = 1;
xzfac = xzfac - 1;
if (xzfac < 1) xzfac = 1;
refresh();
RedrawWindow();
CScrollView::OnRButtonDown(nFlags, point);
}