?? zfview.cpp
字號:
// zfView.cpp : implementation of the CZfView class
//
#include "stdafx.h"
#include "zf.h"
#include "zfDoc.h"
#include "zfView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CZfView
IMPLEMENT_DYNCREATE(CZfView, CView)
BEGIN_MESSAGE_MAP(CZfView, CView)
//{{AFX_MSG_MAP(CZfView)
ON_WM_LBUTTONDOWN()
ON_WM_CANCELMODE()
ON_WM_LBUTTONUP()
ON_WM_CAPTURECHANGED()
ON_COMMAND(IDM_POINT, OnPoint)
ON_COMMAND(IDM_LINE, OnLine)
ON_COMMAND(IDM_CIRCLE, OnCircle)
ON_COMMAND(IDM_CRECT, OnCrect)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CZfView construction/destruction
CZfView::CZfView()
{
// TODO: add construction code here
type =0;
point1=0;
}
CZfView::~CZfView()
{
}
BOOL CZfView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CZfView drawing
void CZfView::OnDraw(CDC* pDC)
{
CZfDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CZfView printing
BOOL CZfView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CZfView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CZfView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CZfView diagnostics
#ifdef _DEBUG
void CZfView::AssertValid() const
{
CView::AssertValid();
}
void CZfView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CZfDoc* CZfView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CZfDoc)));
return (CZfDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CZfView message handlers
void CZfView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
point1=point;
CView::OnLButtonDown(nFlags, point);
}
void CZfView::OnCancelMode()
{
CView::OnCancelMode();
// TODO: Add your message handler code here
}
void CZfView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
CPen pen1;
pen1.CreatePen(4,6,col1);
dc.SelectObject(&pen1);
switch(type)
{
case 1: dc.SetPixel(point,col1);
break;
case 2: dc.MoveTo(point1);
dc.LineTo(point);
break;
case 3: dc.Ellipse(CRect(point1,point));
break;
case 4: dc.Rectangle(CRect(point1,point));
break;
}
//dc.MoveTo(point1);
//dc.LineTo(point);
CView::OnLButtonUp(nFlags, point);
}
void CZfView::OnCaptureChanged(CWnd *pWnd)
{
// TODO: Add your message handler code here
CView::OnCaptureChanged(pWnd);
}
void CZfView::OnPoint()
{
// TODO: Add your command handler code here
type=1;
CColorDialog d1_color;
d1_color.DoModal();
col1=d1_color.GetColor();
}
void CZfView::OnLine()
{
// TODO: Add your command handler code here
type=2;
CColorDialog d1_color;
d1_color.DoModal();
col1=d1_color.GetColor();
}
void CZfView::OnCircle()
{
// TODO: Add your command handler code here
type=3;
CColorDialog d1_color;
d1_color.DoModal();
col1=d1_color.GetColor();
}
void CZfView::OnCrect()
{
// TODO: Add your command handler code here
type=4;
CColorDialog d1_color;
d1_color.DoModal();
col1=d1_color.GetColor();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -