|
// FaceView.cpp : implementation of the CFaceView class
//
#include "stdafx.h"
#include "Face.h"
#include "FaceDoc.h"
#include "FaceView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFaceView
IMPLEMENT_DYNCREATE(CFaceView, CView)
BEGIN_MESSAGE_MAP(CFaceView, CView)
//{{AFX_MSG_MAP(CFaceView)
ON_COMMAND(ID_CANCEL_EDIT_SRVR, OnCancelEditSrvr)
ON_COMMAND(ID_FACE_HAPPY, OnFaceHappy)
ON_COMMAND(ID_FACE_SAD, OnFaceSad)
ON_WM_PAINT()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CFaceView construction/destruction
CFaceView::CFaceView()
{
// TODO: add construction code here
}
CFaceView::~CFaceView()
{
}
BOOL CFaceView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CFaceView drawing
void CFaceView::OnDraw(CDC* pDC)
{
CFaceDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CFaceView printing
BOOL CFaceView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CFaceView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CFaceView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// OLE Server support
// The following command handler provides the standard keyboard
// user interface to cancel an in-place editing session. Here,
// the server (not the container) causes the deactivation.
void CFaceView::OnCancelEditSrvr()
{
GetDocument()->OnDeactivateUI(FALSE);
}
/////////////////////////////////////////////////////////////////////////////
// CFaceView diagnostics
#ifdef _DEBUG
void CFaceView::AssertValid() const
{
CView::AssertValid();
}
void CFaceView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CFaceDoc* CFaceView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFaceDoc)));
return (CFaceDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CFaceView message handlers
void CFaceView::OnFaceHappy()
{
GetDocument()->SetHappy();
RedrawWindow();
}
void CFaceView::OnFaceSad()
{
GetDocument()->SetSad();
RedrawWindow();
}
void CFaceView::OnPaint()
{
CPaintDC dc(this); // device context for painting
CFaceDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// Drawing simple (not yellow) face
RECT w1;
GetWindowRect(&w1);
CRect w = w1;
int width,height;
width = w.Width();
height = w.Height();
dc.Ellipse(0,0,width,height);
if(pDoc->m_nHappy==1)
{
dc.Arc(int(0.233 * width),int(0.466 * height),int(0.766 * width),int(0.866 * height),
int(0.233 * width),int(0.666 * height),int(0.766 * width),int(0.666 * height));
}
else
{
dc.Arc(int(0.233 * width),int(0.633 * height),int(0.766 * width),int(1.033 * height),
int(0.866 * width),int(0.833 * height),int(0.233 * width),int(0.833 * height));
}
dc.Ellipse(int(0.266 * width), int(0.2 * height), int(0.466 * width), int(0.4 * height));
dc.Ellipse(int(0.733 * width), int(0.2 * height), int(0.533 * width), int(0.4 * height));
// Do not call CView::OnPaint() for painting messages
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been programming since I was really young. Started with HTML and Basic, looked at Pascal and Java, keen on Visual Basic and Visual C++, thinking about .NET and C#.