VC++深入详解-第四章学习心得


这一章节主要讲解了 简单的绘图

主要是通过一些小的例子让我们学会了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);



}


 

 后面还有几个小例子就没有一一去写了,基本类似,因为个人觉得实用性不大,需要看相关绘图方面的资料时再回头来看

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值