//只添加了这部分的代码,已经能去掉了。
void CMyView::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
CScrollView::OnWindowPosChanging(lpwndpos);
// TODO: Add your message handler code here
ShowScrollBar (SB_BOTH, FALSE);
ModifyStyle (WS_HSCROLL, 0, SWP_DRAWFRAME);
}
//这部分的代码没有测试
但是为为了能使视图滚动,必须响应ON_WM_HSCROLL(),设置视图的Pos,如下:
void CBaseView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
CPoint pt = GetScrollPosition();
CSize sz = GetTotalSize();
if(nSBCode == SB_LEFT || nSBCode == SB_LINELEFT || nSBCode == SB_PAGELEFT)
{
pt.x -= 10;
pt.x = (pt.x<0)?0:pt.x;
}
else if(nSBCode == SB_RIGHT || nSBCode == SB_LINERIGHT || nSBCode == SB_PAGERIGHT)
{
pt.x += 10;
pt.x = (pt.x>sz.cx)?sz.cx:pt.x;
}
else if(nSBCode == SB_THUMBPOSITION || nSBCode == SB_THUMBTRACK)
{
pt.x = ((LONG)nPos>=0 && (LONG)nPos<sz.cx)?nPos:pt.x;
}
ScrollToPosition(pt);
Invalidate();
}