【VC开源代码栏目提醒】:网学会员,鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“CText_7View.cpp”一文,供大家参考学习!
// CText_7View.cpp : implementation of the CCText_7View class
//
#include "stdafx.h"
#include "CText_7.h"
#include "CText_7Doc.h"
#include "CText_7View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCText_7View
IMPLEMENT_DYNCREATE(CCText_7View, CView)
BEGIN_MESSAGE_MAP(CCText_7View, CView)
//{{AFX_MSG_MAP(CCText_7View)
ON_WM_TIMER()
ON_WM_CREATE()
//}}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_7View construction/destruction
CCText_7View::CCText_7View()
{
// TODO: add construction code here
m_width=0;
}
CCText_7View::~CCText_7View()
{
}
BOOL CCText_7View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCText_7View drawing
void CCText_7View::OnDraw(CDC* pDC)
{
CCText_7Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
// CString str;
// str="Hello,World!";
// CClientDC dc(this);
// dc.TextOut(50,100,str);
}
/////////////////////////////////////////////////////////////////////////////
// CCText_7View printing
BOOL CCText_7View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCText_7View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCText_7View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCText_7View diagnostics
#ifdef _DEBUG
void CCText_7View::AssertValid() const
{
CView::AssertValid();
}
void CCText_7View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCText_7Doc* CCText_7View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCText_7Doc)));
return (CCText_7Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCText_7View message handlers
void CCText_7View::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
m_width+=5;
CClientDC dc(this);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
CRect rect;
rect.left=0;
rect.top=0;
rect.right=m_width;
rect.bottom=rect.top+tm.tmHeight;
dc.SetTextColor(RGB(255,0,0));
CString str;
str="Hello,World! Hello,World! ";
// dc.TextOut(50,100,str);
dc.DrawText(str,rect,DT_LEFT);
CSize sz=dc.GetTextExtent(str);
if(m_width>sz.cx+100)
{
m_width=0;
dc.SetTextColor(RGB(255,255,255)); //字符串颜色为白色
dc.TextOut(0,0,str);//覆盖在原颜色上
}
CView::OnTimer(nIDEvent);
}
int CCText_7View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
SetTimer(1,50,NULL); //设定定时器
return 0;
}
上一篇:
CText_7Doc.cpp
下一篇:
临床前药物安全性评价中毒性病理学新技术的应用