📄 face2view.cpp
字号:
// face2View.cpp : implementation of the CFace2View class
//
#include "stdafx.h"
#include "face2.h"
#include "face2Doc.h"
#include "face2View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFace2View
IMPLEMENT_DYNCREATE(CFace2View, CView)
BEGIN_MESSAGE_MAP(CFace2View, CView)
//{{AFX_MSG_MAP(CFace2View)
ON_WM_TIMER()
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
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()
/////////////////////////////////////////////////////////////////////////////
// CFace2View construction/destruction
CFace2View::CFace2View()
{
// TODO: add construction code here
m_titan.LoadBitmap(IDB_TITAN);
m_angel.LoadBitmap(IDB_BITMAP1);
}
CFace2View::~CFace2View()
{
}
BOOL CFace2View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CFace2View drawing
void CFace2View::OnDraw(CDC* pDC)
{
CFace2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CDC Dc;
if(Dc.CreateCompatibleDC(pDC)==FALSE)
AfxMessageBox("error");
Dc.SelectObject(m_titan);
pDC->StretchBlt(pDoc->m_size.cx,pDoc->m_size.cy,200,200,&Dc,0,0,160,160,SRCCOPY);
/* UINT nTimerID;
int time = 10;
nTimerID = SetTimer(1,10000*time,NULL);
if(0 == nTimerID)
AfxMessageBox("error");
*/
}
/////////////////////////////////////////////////////////////////////////////
// CFace2View printing
BOOL CFace2View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CFace2View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CFace2View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CFace2View diagnostics
#ifdef _DEBUG
void CFace2View::AssertValid() const
{
CView::AssertValid();
}
void CFace2View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CFace2Doc* CFace2View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFace2Doc)));
return (CFace2Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CFace2View message handlers
void CFace2View::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
// AfxMessageBox("error");
CView::OnTimer(nIDEvent);
}
void CFace2View::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
}
void CFace2View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CFace2Doc * pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect rect = CRect(pDoc->m_size.cx,pDoc->m_size.cy,pDoc->m_size.cx+160,pDoc->m_size.cy+160);
if(rect.PtInRect(point))
{
m_b = TRUE;
m_size2.cx = point.x - rect.left;
m_size2.cy = point.y - rect.top;
}
CView::OnLButtonDown(nFlags, point);
}
void CFace2View::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CFace2Doc * pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(m_b == TRUE)
{
pDoc->m_size.cx = point.x - m_size2.cx;
pDoc->m_size.cy = point.y - m_size2.cy;
Invalidate();
pDoc->SetModifiedFlag();
}
CView::OnMouseMove(nFlags, point);
}
void CFace2View::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_b = FALSE;
CView::OnLButtonUp(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -