void CurveWnd::onSize(HWND hwnd, UINT state, int cx, int cy){ int nMax, nPos; nPos = getScrollPos(SB_HORZ); nMax = canvas.cx - 1; if(cx > canvas.cx - nPos){ if(cx >= canvas.cx) nPos = 0; else nPos = canvas.cx - cx; } setScrollInfo(SB_HORZ, 0, nMax, cx, nPos); nPos = getScrollPos(SB_VERT); nMax = canvas.cy - 1; if(cy > canvas.cy - nPos){ if(cy >= canvas.cy) nPos = 0; else nPos = canvas.cy - cy; } setScrollInfo(SB_VERT, 0, nMax, cy, nPos); }
void CurveWnd::resetScroll(){ RECT cr; GetClientRect(hwnd, &cr); setScrollInfo(SB_HORZ, 0, canvas.cx, cr.right, 0); setScrollInfo(SB_VERT, 0, canvas.cy, cr.bottom, 0); }
LRESULT CDataView::OnSize(UINT state, CSize Size) { if (IsWindow() && Size.cx != 0 && Size.cy != 0) { CPoint pt = getScrollPt(); setScrollInfo(pt.x, pt.y); // Invalidate(); // UpdateWindow(); } return 0; }
void CDataView::setScale(double newScale) { newScale = fixZoomScale(newScale); CRect rec; GetClientRect(rec); CPoint pt = getScrollPt(); double ratio; if (newScale < m_scale) { ratio = 1.0 - newScale/m_scale; CPoint offset(rec.Width()*ratio, rec.Height()*ratio); pt.x = pt.x / (m_scale/newScale) - offset.x/2; pt.y = pt.y / (m_scale/newScale) - offset.y/2; }else { ratio = 1.0 - m_scale/newScale; CPoint offset(rec.Width()*ratio, rec.Height()*ratio); pt.x = (pt.x + offset.x/2) / (m_scale/newScale); pt.y = (pt.y + offset.y/2) / (m_scale/newScale); } // pt += offset; m_scale = newScale; setScrollInfo(pt.x, pt.y); }
void CDataView::setZoomWindow(double newScale, int hPos, int vPos) { m_scale = fixZoomScale(newScale); setScrollInfo(hPos*m_scale, vPos*m_scale); }