C++画扇形

// DrawView.cpp : implementation of the CDrawView class // #include "stdafx.h" #include "Draw.h" #include "DrawDoc.h" #include "DrawView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif / // CDrawView IMPLEMENT_DYNCREATE(CDrawView, CView) BEGIN_MESSAGE_MAP(CDrawView, CView) //{{AFX_MSG_MAP(CDrawView) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_MOUSEMOVE() //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() / // CDrawView construction/destruction CDrawView::CDrawView() { // TODO: add construction code here m_bDraw=false; m_ptOrigin=0; m_ptOld=0; } CDrawView::~CDrawView() { } BOOL CDrawView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } / // CDrawView drawing void CDrawView::OnDraw(CDC* pDC) { CDrawDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here } / // CDrawView printing BOOL CDrawView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CDrawView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CDrawView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } / // CDrawView diagnostics #ifdef _DEBUG void CDrawView::AssertValid() const { CView::AssertValid(); } void CDrawView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CDrawDoc* CDrawView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDrawDoc))); return (CDrawDoc*)m_pDocument; } #endif //_DEBUG / // CDrawView message handlers //DEL void CDrawView::OnLButtonDown(UINT nFlags, CPoint point) //DEL { //DEL // TODO: Add your message handler code here and/or call default //DEL MessageBox("view clicked"); //DEL CView::OnLButtonDown(nFlags, point); //DEL } void CDrawView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default // MessageBox("view clicked"); m_bDraw=true; m_ptOrigin=m_ptOld=point; 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); */ /* CDC *pDC=GetDC(); pDC->MoveTo(m_ptOrigin); pDC->LineTo(point); ReleaseDC(pDC); */ //CClientDC dc(this); /*CClientDC dc(GetParent()); dc.MoveTo(m_ptOrigin); dc.LineTo(point); */ // CWindowDC dc(GetParent()); /* CWindowDC dc(GetDesktopWindow()); dc.MoveTo(m_ptOrigin); dc.LineTo(point); */ /*颜色线条*/ /* CPen pen(PS_DASH,1,RGB(255,0,0)); CClientDC dc(this); CPen *pOldPen=dc.SelectObject(&pen); dc.MoveTo(m_ptOrigin); dc.LineTo(point); */ /* CBrush brush(RGB(255,0,0)); CClientDC dc(this); dc.FillRect(CRect(m_ptOrigin,point),&brush); */ m_bDraw=false; CView::OnLButtonUp(nFlags, point); } void CDrawView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CPen pen(PS_SOLID,1,RGB(255,0,0)); CClientDC dc(this); CPen *pOldPen=dc.SelectObject(&pen); if(m_bDraw==true) { /** 连续 dc.MoveTo(m_ptOrigin); dc.LineTo(point); m_ptOrigin=point; */ dc.MoveTo(m_ptOrigin); dc.LineTo(m_ptOld); // dc.MoveTo(m_ptOrigin); dc.MoveTo(m_ptOld); dc.LineTo(point); m_ptOld=point; } dc.SelectObject(pOldPen); CView::OnMouseMove(nFlags, point); } //DEL void CDrawView::OnCancelMode() //DEL { //DEL CView::OnCancelMode(); //DEL //DEL // TODO: Add your message handler code here //DEL //DEL }

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值