?? 302005.txt
字號(hào):
// 302005人機(jī)交互View.cpp : implementation of the CMy302005View class
//
#include "stdafx.h"
#include "302005人機(jī)交互.h"
#include "302005人機(jī)交互Doc.h"
#include "302005人機(jī)交互View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMy302005View
IMPLEMENT_DYNCREATE(CMy302005View, CView)
BEGIN_MESSAGE_MAP(CMy302005View, CView)
//{{AFX_MSG_MAP(CMy302005View)
ON_COMMAND(IDM_DOT, OnDot)
ON_COMMAND(IDM_LINE, OnLine)
ON_COMMAND(IDM_TRCTANGLE, OnTrctangle)
ON_COMMAND(IDM_TRIANGLE, OnTriangle)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CMy302005View construction/destruction
CMy302005View::CMy302005View()
{
// TODO: add construction code here
m_nDrawType=0; //這兩行為成員函數(shù)的初始化
m_ptOrigin=0;
}
CMy302005View::~CMy302005View() //析構(gòu)函數(shù),釋放不必要空間
{
}
BOOL CMy302005View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMy302005View drawing
void CMy302005View::OnDraw(CDC* pDC)
{
CMy302005Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMy302005View printing
BOOL CMy302005View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMy302005View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMy302005View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMy302005View diagnostics
#ifdef _DEBUG
void CMy302005View::AssertValid() const
{
CView::AssertValid();
}
void CMy302005View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMy302005Doc* CMy302005View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy302005Doc)));
return (CMy302005Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMy302005View message handlers
void CMy302005View::OnDot()
{
// TODO: Add your command handler code here
m_nDrawType=1;
}
void CMy302005View::OnLine()
{
// TODO: Add your command handler code here
m_nDrawType=2;
}
void CMy302005View::OnTrctangle()
{
// TODO: Add your command handler code here
m_nDrawType=3;
}
void CMy302005View::OnTriangle()
{
// TODO: Add your command handler code here
m_nDrawType=4;
}
void CMy302005View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptOrigin=point;
CView::OnLButtonDown(nFlags, point);
}
void CMy302005View::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
CPen pen(PS_SOLID,1,RGB(255,0,0)); //設(shè)置顏色為紅色
dc.SelectObject(&pen);
CBrush *pBrush=CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH)); //返回CBrush的指針,利用HBRUSH為了強(qiáng)制轉(zhuǎn)換
dc.SelectObject(pBrush); //將畫刷加入表中,現(xiàn)在使用的是透明的畫刷
switch(m_nDrawType) //當(dāng)m_nDrawType分別取1,2,3,4時(shí)候分別
{ //畫出不同形狀的圖形
case 1:
dc.SetPixel(point,RGB(255,0,0));
break;
case 2:
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
break;
case 3:
dc.Rectangle(CRect(m_ptOrigin,point));
break;
case 4:
dc.Ellipse(CRect(m_ptOrigin,point));
break;
CView::OnLButtonUp(nFlags, point);
CView::OnLButtonUp(nFlags, point);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -