画图View.cpp
上传用户:tjxl888
上传日期:2022-07-19
资源大小:7312k
文件大小:3k
- // 画图View.cpp : C画图View 类的实现
- //
- #include "stdafx.h"
- #include "画图.h"
- #include "画图Doc.h"
- #include "画图View.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // C画图View
- IMPLEMENT_DYNCREATE(C画图View, CView)
- BEGIN_MESSAGE_MAP(C画图View, CView)
- // 标准打印命令
- ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_MOUSEMOVE()
- END_MESSAGE_MAP()
- // C画图View 构造/析构
- C画图View::C画图View()
- : m_point(0)
- , m_b(false)
- {
- m_point=0;// TODO: 在此处添加构造代码
- }
- C画图View::~C画图View()
- {
- }
- BOOL C画图View::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: 在此处通过修改
- // CREATESTRUCT cs 来修改窗口类或样式
- return CView::PreCreateWindow(cs);
- }
- // C画图View 绘制
- void C画图View::OnDraw(CDC* /*pDC*/)
- {
- C画图Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if (!pDoc)
- return;
- // TODO: 在此处为本机数据添加绘制代码
- }
- // C画图View 打印
- BOOL C画图View::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // 默认准备
- return DoPreparePrinting(pInfo);
- }
- void C画图View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: 添加额外的打印前进行的初始化过程
- }
- void C画图View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: 添加打印后进行的清理过程
- }
- // C画图View 诊断
- #ifdef _DEBUG
- void C画图View::AssertValid() const
- {
- CView::AssertValid();
- }
- void C画图View::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- C画图Doc* C画图View::GetDocument() const // 非调试版本是内联的
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(C画图Doc)));
- return (C画图Doc*)m_pDocument;
- }
- #endif //_DEBUG
- // C画图View 消息处理程序
- void C画图View::OnLButtonDown(UINT nFlags, CPoint point)
- {
- m_point=point;// TODO: 在此添加消息处理程序代码和/或调用默认值
- m_b=TRUE;
- CView::OnLButtonDown(nFlags, point);
- }
- void C画图View::OnLButtonUp(UINT nFlags, CPoint point)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- /*CDC *pDC=GetDC();
- pDC->MoveTo(m_point);
- pDC->LineTo(point);
- ReleaseDC(pDC);*/
- /*CBitmap bitmap;
- bitmap.LoadBitmap(IDB_BITMAP1);
- CBrush brush(&bitmap);
- dc.FillRect(CRect(m_point,point),&brush);*/
- /*CClientDC dc(this);
- CBrush brush(RGB(0,255,0));
- dc.Rectangle(CRect(m_point,point));
- dc.SelectObject(brush);*/
- m_b=FALSE;
- CView::OnLButtonUp(nFlags, point);
- }
- void C画图View::OnMouseMove(UINT nFlags, CPoint point)
- {
- CClientDC dc(this);
- CPen pen(PS_SOLID,1,RGB(255,0,0));
- CPen *pOldpen=dc.SelectObject(&pen);
- if(m_b==TRUE)
- {
- dc.MoveTo(m_point);
- dc.LineTo(point);
- m_point=point;
- }
- dc.SelectObject(pOldpen);
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- CView::OnMouseMove(nFlags, point);
- }