【VC开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了VC开源代码-CText_6View.cpp的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
// CText_6View.cpp : implementation of the CCText_6View class
//
#include "stdafx.h"
#include "CText_6.h"
#include "CText_6Doc.h"
#include "CText_6View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCText_6View
IMPLEMENT_DYNCREATE(CCText_6View, CView)
BEGIN_MESSAGE_MAP(CCText_6View, CView)
//{{AFX_MSG_MAP(CCText_6View)
ON_WM_CHAR()
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCText_6View construction/destruction
CCText_6View::CCText_6View()
{
// TODO: add construction code here
m_str="";
m_point.x=0;
m_point.y=0;
}
CCText_6View::~CCText_6View()
{
}
BOOL CCText_6View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCText_6View drawing
void CCText_6View::OnDraw(CDC* pDC)
{
CCText_6Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCText_6View printing
BOOL CCText_6View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCText_6View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCText_6View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCText_6View diagnostics
#ifdef _DEBUG
void CCText_6View::AssertValid() const
{
CView::AssertValid();
}
void CCText_6View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCText_6Doc* CCText_6View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCText_6Doc)));
return (CCText_6Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCText_6View message handlers
void CCText_6View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
CFont font;
font.CreatePointFont(300,"华文行楷",NULL);
dc.SelectObject(&font);
m_str+=nChar;
CSize sz=dc.GetTextExtent(m_str);
CPoint pt;
pt.x=m_point.x+sz.cx;
pt.y=m_point.y;
SetCaretPos(pt); //设置插入符的新位置
dc.TextOut(0,0,m_str); //输出字符
CView::OnChar(nChar, nRepCnt, nFlags);
}
int CCText_6View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
CClientDC dc(this);
CFont font;
font.CreatePointFont(300,"华文行楷",NULL); //设置字体的格式
dc.SelectObject(&font);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
CreateSolidCaret(tm.tmAveCharWidth/8,tm.tmHeight); //创建插入符
ShowCaret();
// TODO: Add your specialized creation code here
return 0;
}
void CCText_6View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SetCaretPos(point); //设置插入符的新位置
m_point=point;
CView::OnLButtonDown(nFlags, point);
}
上一篇:
CText_6Doc.cpp
下一篇:
试题库管理系统毕业论文