创建一个CShowForm继承的是CScrollView类,在拖动Scroll的时候在相应位置显示一个递进的数,程序如下,但为何我在点击向右拖动时显示的X是X+2呢,而且我直接点击SCroll(并未拖动他)也会出现数字变化呢?
请给出解决办法,如果要设置Scroll请给出相应代码解释!BOOL CShowForm::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
// TODO: Add your specialized code here and/or call the base class
CString str;
CDC* hdy=GetDC();
CRect current;
GetClientRect(current);
CBrush brush;
if(bDoScroll)
{hdy->FillRect(current,hdy->GetCurrentBrush());
x++;
str.Format("%d",x);
hdy->MoveTo(100,100);
hdy->LineTo(100,200);
hdy->TextOut(100,200,str);
}
return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
}
请给出解决办法,如果要设置Scroll请给出相应代码解释!BOOL CShowForm::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
// TODO: Add your specialized code here and/or call the base class
CString str;
CDC* hdy=GetDC();
CRect current;
GetClientRect(current);
CBrush brush;
if(bDoScroll)
{hdy->FillRect(current,hdy->GetCurrentBrush());
x++;
str.Format("%d",x);
hdy->MoveTo(100,100);
hdy->LineTo(100,200);
hdy->TextOut(100,200,str);
}
return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货