?? ex07_2doc.cpp
字號:
// Ex07_2Doc.cpp : implementation of the CEx07_2Doc class
//
#include "stdafx.h"
#include "Ex07_2.h"
#include "Ex07_2Doc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx07_2Doc
IMPLEMENT_DYNCREATE(CEx07_2Doc, CDocument)
BEGIN_MESSAGE_MAP(CEx07_2Doc, CDocument)
//{{AFX_MSG_MAP(CEx07_2Doc)
// 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
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx07_2Doc construction/destruction
CEx07_2Doc::CEx07_2Doc()
{
// TODO: add one-time construction code here
}
CEx07_2Doc::~CEx07_2Doc()
{
ReInit();
}
BOOL CEx07_2Doc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
ReInit();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CEx07_2Doc serialization
void CEx07_2Doc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CEx07_2Doc diagnostics
#ifdef _DEBUG
void CEx07_2Doc::AssertValid() const
{
CDocument::AssertValid();
}
void CEx07_2Doc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx07_2Doc commands
void CEx07_2Doc::ReInit()
{
CLine *pLine;
POSITION pos=m_LineList.GetHeadPosition();
for(;pos!=NULL;m_LineList.GetNext(pos))
{
pLine=(CLine*)m_LineList.GetAt(pos);
delete pLine;
}
m_LineList.RemoveAll();
m_strList.RemoveAll();
}
void CEx07_2Doc::DrawLine(CDC*pDC)
{
//取得需要重繪的區域
CRect rectClip;
pDC->GetClipBox(&rectClip);
CLine *pLine;
POSITION pos=m_LineList.GetHeadPosition();
for(;pos!=NULL;m_LineList.GetNext(pos))
{
pLine=(CLine*)m_LineList.GetAt(pos);
if(rectClip.PtInRect(pLine->m_StartPt)||rectClip.PtInRect(pLine->m_EndPt))
{
pLine->Draw(pDC);
}
}
}
void CEx07_2Doc::DrawText(CDC*pDC)
{ //取得需要重繪的區域
CRect rectClip,rect;
pDC->GetClipBox(&rectClip);
CSize size;
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int nLineHeight=tm.tmHeight+tm.tmExternalLeading;
CString str;
int line=0;
POSITION pos=m_strList.GetHeadPosition();
for(;pos!=NULL;m_strList.GetNext(pos))
{
str=m_strList.GetAt(pos);
size=pDC->GetTextExtent(str);
rect.SetRect(0,line*nLineHeight,size.cx,line*nLineHeight+size.cy);
if(!(rect&rectClip).IsRectEmpty())pDC->TextOut(0,line*nLineHeight,str);
line++;
}
str=m_strLastLine;
size=pDC->GetTextExtent(str);
rect.SetRect(0,line*nLineHeight,size.cx,line*nLineHeight+size.cy);
if(!(rect&rectClip).IsRectEmpty())
pDC->TextOut(0,line*nLineHeight,str);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -