这一章节主要讲解了 简单的绘图
主要是通过一些小的例子让我们学会了VC++的一些基本操作
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptOrigin = point;
// MessageBox("hello");
CView::OnLButtonDown(nFlags, point);
} void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
/*
//获得窗口的设备描述表
HDC hdc;
hdc = ::GetDC(m_hWnd);
//移动到线条起点
MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,NULL);
//画线
LineTo(hdc,point.x,point.y);
//释放
::ReleaseDC(m_hWnd,hdc);
CView::OnLButtonUp(nFlags, point);
*/ /*
//获得窗口的设备描述表对象的指针
CDC* pDC = GetDC();
pDC->MoveTo(m_ptOrigin);
pDC->LineTo(point);
ReleaseDC(pDC);
CView::OnLButtonUp(nFlags, point);
*/ /*
CClientDC dc(this);
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
CView::OnLButtonUp(nFlags, point);
*/ /*
//CWindowDC wDC(this);
//CWindowDC wDC(GetParent());
CWindowDC wDC(GetDesktopWindow());
wDC.MoveTo(m_ptOrigin);
wDC.LineTo(point);
CView::OnLButtonUp(nFlags, point);
*/ /*
CPen pen(PS_SOLID,1,RGB(255,0,0));
CClientDC dc(this);
CPen* pOldPen = dc.SelectObject(&pen);
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
dc.SelectObject(pOldPen);
CView::OnLButtonUp(nFlags, point);
*/ /*
//定义画刷
CBrush brush(RGB(255,0,0));
//获得窗口的设备描述表对象
CClientDC dc(this);
//画矩形
dc.FillRect(CRect(m_ptOrigin,point),&brush); CView::OnLButtonUp(nFlags, point);
*/ //创建位图
CBitmap bitmap;
//加载位图资源
bitmap.LoadBitmap(IDB_BITMAP1);
//画刷
CBrush brush(&bitmap);
CClientDC dc(this);
dc.FillRect(CRect(m_ptOrigin,point),&brush); CView::OnLButtonUp(nFlags, point); }
后面还有几个小例子就没有一一去写了,基本类似,因为个人觉得实用性不大,需要看相关绘图方面的资料时再回头来看