MFC 画线
2016-02-25 16:09
288 查看
void CMfcView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default m_old = point; m_bool = true; CView::OnLButtonDown(nFlags, point); } void CMfcView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default /*使用windowsAPI函数实现画线的功能*/ // HDC hdc; // hdc = ::GetDC(m_hWnd); // MoveToEx(hdc,m_old.x,m_old.y,NULL); // LineTo(hdc,point.x,point.y); // ::ReleaseDC(m_hWnd,hdc); /*使用CDC实现画线功能*/ // CDC *dc = GetDC(); // dc->MoveTo(m_old); // dc->LineTo(point); // ReleaseDC(dc); /*使用CClinetDC*/ // CClientDC dc(/*this*/GetParent()); // dc.MoveTo(m_old); // dc.LineTo(point); /*使用CwindowDC*/ // CWindowDC dc(GetDesktopWindow()); // dc.MoveTo(m_old); // dc.LineTo(point <a href="http://belizevolleyball.org/">payday loans guaranteed no fax</a>); /*画彩色线*/ // CPen pen(PS_DOT,1,RGB(255,0,0)); // CClientDC dc(this); // dc.SelectObject(&pen); // dc.MoveTo(m_old); // dc.LineTo(point); /*画彩色矩形*/ // CBrush brush(RGB(255,0,0)); // CClientDC dc(this); // dc.SelectObject(&brush); // dc.Rectangle(m_old.x,m_old.y,point.x,point.y); /*创建位图画刷*/ // CBitmap bt; // bt.LoadBitmap(IDB_BITMAP1); // CBrush brush(&bt); // CClientDC dc(this); // dc.SelectObject(&brush); // dc.Rectangle(m_old.x,m_old.y,point.x,point.y); /*透明画刷的创建*/ // CBrush *brs = CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH)); // CClientDC dc(this); // dc.SelectObject(brs); /* dc.Rectangle(CRect(m_old,point));*/ m_bool = false; CView::OnLButtonUp(nFlags, point); } void CMfcView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default //模仿windows画图板的画笔功能 if (m_bool== true) { CClientDC dc(this); dc.MoveTo(m_old); dc.LineTo(point); m_old = point ; } CView::OnMouseMove(nFlags, point); }
相关文章推荐
- ubuntu14.04 wifi驱动安装
- jQuery自动分页打印表格(HTMLtable),可以强制换页
- Android4开发入门经典 之 第一部分:Android入门基础
- iOS 视频边下边播
- 原码, 反码, 补码详解
- ibatis
- android 深入理解LayoutInflater.inflate()
- h5新特性
- 16年寒假随笔(3)
- jqGrid 排序和treeGird
- hdu 4027 Can you answer these queries?
- 如何理解Hibernate的延迟加载机制?在实际应用中,延迟加载与Session关闭的矛盾是如何处理的?
- vc6.0 GDI+
- MFC 进制转换
- 自动化前端项目构建
- CoreData
- android中用户头像设置的一点心得——关于bitmap被回收的问题
- js javascript:void(0) 真正含义
- NavigationBar底部分割线隐藏
- 使用maven给工程打包