在MFC下的 brush画刷有没有方法可以画个圆,然后按一条直线运动
{
m_rect = CRect( 0, 210, 100, 310 );
m_bRight = TRUE;
CBrush brush( RGB( 255, 0, 255 ) );
CDC* pDC = GetDC();
pDC->FillRect( CRect( 0, 0, 100, 100 ) , &brush );
//
CRect rect( 0, 0, 100, 100 );
HDC hDC = ::GetDC( NULL );
::FillRect( hDC, &rect, brush );
SetTimer( 1, 10, NULL );
}
void CJisuanqiDlg::OnTimer(UINT nIDEvent)
{
if( 1 == nIDEvent )
{
int nStep = 1;
if( m_bRight )
m_rect.OffsetRect( nStep, 0 );
else
m_rect.OffsetRect( - nStep, 0 );
if( m_rect.right > 500 || m_rect.left < 0 )
{
m_bRight = !m_bRight;
}
//
// Invalidate();
CDC* pDC = GetDC();
// back
CRect rect( 0, 200, 600, 800 );
CBrush brushBack( RGB( 255, 255, 255 ) );
pDC->FillRect( rect, &brushBack );
//
CBrush brush( RGB( 128, 0, 128 ) );
pDC->FillRect( m_rect, &brush );
CRect rect( 0, 0, 100, 100 );
HDC hDC = ::GetDC( NULL );
::FillRect( hDC, &rect, brush );
}
CDialog::OnTimer(nIDEvent);
}
这是矩形运动的代码,
我用Ellipse画一个圆,不知道怎么运动;
CDC* pDC = GetDC();
pDC-> SelectObject(new CBrush(RGB(128,255,255)));
pDC->Ellipse(0,0,100,100);