// Eg9_3View.cpp : implementation of the CEg9_3View class
//

#include "stdafx.h"
#include "Eg9_3.h"

#include "Eg9_3Doc.h"
#include "Eg9_3View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEg9_3View

IMPLEMENT_DYNCREATE(CEg9_3View, CView)

BEGIN_MESSAGE_MAP(CEg9_3View, CView)
	//{{AFX_MSG_MAP(CEg9_3View)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CEg9_3View construction/destruction

CEg9_3View::CEg9_3View()
{
	// TODO: add construction code here

}

CEg9_3View::~CEg9_3View()
{
}

BOOL CEg9_3View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CEg9_3View drawing

void CEg9_3View::OnDraw(CDC* pDC)
{
	CEg9_3Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	CClientDC dc(this);
		CBrush Brush;
	    CBrush *PtrOldBrush;
	    PtrOldBrush=dc.GetCurrentBrush();
        Brush.CreateSolidBrush(RGB(0,200,0));
        dc.SelectObject(&Brush);
		dc.Rectangle(10,150,400,300);
	    dc.SelectObject(PtrOldBrush);
        Brush.DeleteObject();



	CFont Font1,Font2;
	        //两个字体对象，函数返回时，应用框架会将其删除
	CFont * pOldFont;   //指向字体对象的指针，用以跟踪DC中的原字体

	Font1.CreateFont (-25,                     //字体字符的逻辑高度                        
		           0,                       //字符平均宽度取默认值                           
		           0,                       //文本行角度为0，水平
				   0,                       //字符角度为0，正立                       
				   FW_NORMAL,               //正常体               
				   FALSE,                   //不倾斜
				   FALSE,                   //不加下划线
				   FALSE,                   //不加删除线
				   ANSI_CHARSET,            //标准字符集
				   OUT_DEFAULT_PRECIS,
			       CLIP_DEFAULT_PRECIS,
			       DEFAULT_QUALITY,
				   DEFAULT_PITCH|FF_ROMAN,
				   "Times New Roman");      //Times New Roman字体
	pOldFont=pDC->SelectObject(&Font1);
	pDC->TextOut (0,0,"This is Times New Roman Font!");

	Font2.CreateFont (-50,                                             
		           0,                                                  
		           0,                       
				   0,                                              
				   FW_NORMAL,                              
				   FALSE,                  
				   FALSE,                   
				   FALSE,                   
				   GB2312_CHARSET,            //中文字符集
				   OUT_STROKE_PRECIS,
				   CLIP_STROKE_PRECIS,
				   DRAFT_QUALITY,
				   VARIABLE_PITCH,
				   "宋体");           //宋体
	pOldFont=pDC->SelectObject(&Font2);
	pDC->SetTextColor (RGB(255,0,0));  //设置字体的颜色
	
	pDC->TextOut (0,50,"这是宋体！");

    //将DC中原来的字体选入，恢复DC原状态
	pDC->SelectObject (pOldFont);


        

}

/////////////////////////////////////////////////////////////////////////////
// CEg9_3View printing

BOOL CEg9_3View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CEg9_3View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CEg9_3View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CEg9_3View diagnostics

#ifdef _DEBUG
void CEg9_3View::AssertValid() const
{
	CView::AssertValid();
}

void CEg9_3View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CEg9_3Doc* CEg9_3View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEg9_3Doc)));
	return (CEg9_3Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CEg9_3View message handlers
