我是使用 MFC 滚动视图的新手,我在 ScrollView 类的 onPaint 函数中显示大图像。这是以下代码的 On initial update 功能
void CCenterImageView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = m_matImage.cols;
sizeTotal.cy = m_matImage.rows;
SetScrollSizes(MM_TEXT, sizeTotal,sizeTotal);
}
void CCenterImageView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
//Invalidate();
}
void CCenterImageView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
UpdateData();
//Invalidate();
}
void CCenterImageView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CView::OnPaint() for painting messages
if(m_CVvImageObj.GetImage())
{
//this function blit the bitmap on the screen height and width are more than 1000 pixels
m_CVvImageObj.Show(dc.GetSafeHdc(),0,0,m_CVvImageObj.Width(),m_CVvImageObj.Height());
}
}
通过使用这个http://www.functionx.com/visualc/views/scrollview.htm我可以看到垂直和水平滚动,但按下它们不会改变视图上的任何内容。请指导我如何在用户点击时移动滚动并更改视图?