码迷,mamicode.com
首页 > 其他好文 > 详细

画图2

时间:2015-07-17 15:42:36      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:


void CXuexiView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
UpdateData(FALSE);
m_origin=point;
CView::OnLButtonDown(nFlags, point);
}

void CXuexiView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default

/*HDC hdc;
hdc=::GetDC(m_hWnd);//m_hwnd获得当前的窗口
MoveToEx(hdc,m_origin.x,m_origin.y,NULL);
LineTo(hdc,point.x,point.y);
::ReleaseDC(m_hWnd,hdc);
*/

/*CDC *pdc=GetDC();//专门用于画图的
pdc->MoveTo(m_origin);
pdc->LineTo(point);
ReleaseDC(pdc);*/

//CClientDC dc(this);//得到当前窗口的指针 CClientDC 自动析构
/* CClientDC dc(GetParent());//这样就能画到菜单栏上
dc.MoveTo(m_origin);
dc.LineTo(point);*/

// CWindowDC dc(this);//this 表示的是view对应的窗口的指针
//CWindowDC dc(GetParent());// CWindowDC dc(this);表示可以在非客户区进行作图
//CWindowDC dc(GetDesktopWindow());//使之能够画到桌面上
//dc.MoveTo(m_origin);
//dc.LineTo(point);

/*CPen pen(PS_SOLID,3,RGB(255,0,0));
CClientDC dc(this);
CPen *poldpen=dc.SelectObject(&pen);//设备描述表,储存指针 后面还原
dc.MoveTo(m_origin);
dc.LineTo(point);
dc.SelectObject(poldpen);//需要把设备描述表选择的画笔还原回去*/

//创建颜色画刷
//CBrush brush(RGB(255,0,0));
//CClientDC dc(this);
//dc.FillRect(CRect(m_origin,point),&brush);
//创建位图 画刷
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);
CBrush brush(&bitmap);
CClientDC dc(this);
dc.FillRect(CRect(m_origin,point),&brush);
CView::OnLButtonUp(nFlags, point);

}

画图2

标签:

原文地址:http://www.cnblogs.com/llforeverlove/p/4654489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!