我是新來的MFC滾動視圖,我在我的ScrollView類的函數onPaint中顯示大圖像。這裏是在初始更新功能,下面的代碼MFC CScrollView滾動不起作用
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我可以看到垂直和水平滾動,但按他們不改變對圖什麼。請引導我如何在用戶點擊時移動滾動並更改視圖?