还是更新的问题
void CMy11View::OnInitialUpdate()
{
CView::OnInitialUpdate();
a = 0;
// TODO: Add your specialized code here and/or call the base class
SetTimer(1,20,NULL);
}
void CMy11View::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
a+=100;
if(a>50000)
a = 0;
Invalidate();
CView::OnTimer(nIDEvent);
}
BOOL CMy11View::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
}
void CMy11View::OnPaint()
{
CPaintDC dc(this); // device context for painting
GetClientRect(&rect);
CMemDC memDC(&dc, &rect);
if(m_dcBackground.GetSafeHdc()== NULL|| (m_bitmapBackground.m_hObject == NULL))
{
m_dcBackground.CreateCompatibleDC(&dc);
m_bitmapBackground.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height()) ;
m_pBitmapOldBackground = m_dcBackground.SelectObject(&m_bitmapBackground) ;
//DrawMeterBackground(&m_dcBackground, rect);
CBrush brushFill, *pBrushOld;
// 背景色黑色
brushFill.DeleteObject();
brushFill.CreateSolidBrush(RGB(255, 255, 255));
pBrushOld = m_dcBackground.SelectObject(&brushFill);
m_dcBackground.Rectangle(rect);
m_dcBackground.SelectObject(pBrushOld);
}
memDC.BitBlt(0, 0, rect.Width(), rect.Height(),
&m_dcBackground, 0, 0, SRCCOPY) ;
// TODO: Add your message handler code here
int i;
int x[20],y[20];
CPen hPen;
POINT w[5];
x[0]=a/100+10;
x[1]=a/100+30;
x[2]=a/100+80;
x[3]=a/100+30;
x[4]=a/100+10;
y[0]=100;
y[1]=100;
y[2]=250;
y[3]=400;
y[4]=400;
for (i=0;i<5;i++)
{ w[i].x=x[i];
w[i].y=y[i];
}
//CClientDC dc(this);
//hPen=CreatePen(PS_SOLID,1,RGB(255,0,0));
CRgn argn,Brgn;
CBrush abrush(RGB(40,30,20));
argn.CreatePolygonRgn(w, 5, 1);// point为CPoint数组,
memDC.FillRgn(&argn, &abrush);
abrush.DeleteObject();
// Do not call CView::OnPaint() for painting messages
}
这是网上找来的一个双缓冲
原作者姓名 戚高
他的ontimer里的a+=100要是改的大一点,也就是箭头每次移动的距离大点的话,就会有点闪了,如a+=600;这是为什么啊~????????????
我的这个问题也在
http://community.csdn.net/Expert/topic/4928/4928973.xml?temp=.8795435
发过,解决了两个一起给分