源代码为
void CMyDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptOrigin = point;
SetCapture();
b_Capture = true; //捕捉就开始画图
CView::OnLButtonDown(nFlags, point);
}
void CMyDrawView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (b_Capture ) //开始画图
{
CClientDC dc(this);
CBrush *pbrush = CBrush::FromHandle((HBRUSH)GetStockObje(NULL_BRUSH));
dc.SelectObject(pbrush); int nMode = dc.SetROP2(R2_NOT); //擦除原来的图形
dc.Rectangle(CRect(m_ptOrigin, m_ptEnd));
dc.SetROP2(nMode);
m_ptEnd = point;
int nMode = dc.SetROP2(R2_NOT);
dc.Rectangle(CRect(m_ptOrigin, m_ptEnd));
dc.SetROP2(nMode); }
}
void CMyDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(b_Capture)
{
ReleaseCapture();
b_Capture = false; //取消画图 CClientDC dc(this); CBrush *pbrush = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
dc.SelectObject(pbrush);
m_ptEnd = point;
dc.Rectangle(CRect(m_ptOrigin, m_ptEnd));
}
CView::OnLButtonUp(nFlags, point);
}我想是想的是画图的时候平滑渐变的效果, 怎么样才能,实现,其中,
MouseMove的事件中的处理, 存在, 画矩形的时候,虽然能渐变了,但是有的边却存在着闪烁的问题,怎么解决呢??
void CMyDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptOrigin = point;
SetCapture();
b_Capture = true; //捕捉就开始画图
CView::OnLButtonDown(nFlags, point);
}
void CMyDrawView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (b_Capture ) //开始画图
{
CClientDC dc(this);
CBrush *pbrush = CBrush::FromHandle((HBRUSH)GetStockObje(NULL_BRUSH));
dc.SelectObject(pbrush); int nMode = dc.SetROP2(R2_NOT); //擦除原来的图形
dc.Rectangle(CRect(m_ptOrigin, m_ptEnd));
dc.SetROP2(nMode);
m_ptEnd = point;
int nMode = dc.SetROP2(R2_NOT);
dc.Rectangle(CRect(m_ptOrigin, m_ptEnd));
dc.SetROP2(nMode); }
}
void CMyDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(b_Capture)
{
ReleaseCapture();
b_Capture = false; //取消画图 CClientDC dc(this); CBrush *pbrush = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH));
dc.SelectObject(pbrush);
m_ptEnd = point;
dc.Rectangle(CRect(m_ptOrigin, m_ptEnd));
}
CView::OnLButtonUp(nFlags, point);
}我想是想的是画图的时候平滑渐变的效果, 怎么样才能,实现,其中,
MouseMove的事件中的处理, 存在, 画矩形的时候,虽然能渐变了,但是有的边却存在着闪烁的问题,怎么解决呢??
不好意思, 麻烦大家了, 就是少了一个条件判断语句,呵呵, 这样实现渐变的效果,呵呵,
至于有位仁兄说的, 双缓冲,我也试过了,呵呵
这个也用双缓冲?成本过高了吧