www.pudn.com > Triumph.rar > TriumphView.cpp


// TriumphView.cpp : implementation of the CTriumphView class 
// 
 
#include "stdafx.h" 
#include "Triumph.h" 
 
#include "TriumphDoc.h" 
#include "TriumphView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CTriumphView 
 
IMPLEMENT_DYNCREATE(CTriumphView, CScrollView) 
 
BEGIN_MESSAGE_MAP(CTriumphView, CScrollView) 
	//{{AFX_MSG_MAP(CTriumphView) 
		// 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() 
 
///////////////////////////////////////////////////////////////////////////// 
// CTriumphView construction/destruction 
 
CTriumphView::CTriumphView() 
{ 
	// TODO: add construction code here 
	Path_Cet_4=CString("cet_4"); 
	Path_Cet_6=CString("cet_6"); 
	Path_KaoYan=CString("KaoYan"); 
} 
 
CTriumphView::~CTriumphView() 
{ 
} 
 
BOOL CTriumphView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CScrollView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CTriumphView drawing 
 
void CTriumphView::OnDraw(CDC* pDC) 
{ 
	CTriumphDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: calculate the total size of this view 
	pDC->SetBkMode(TRANSPARENT); 
	CStringList& notelist=pDoc->GetNote(); 
	CSize sizeTotal; 
	sizeTotal.cx = 100; 
	sizeTotal.cy = notelist.GetCount()/2*45; 
	SetScrollSizes(MM_TEXT, sizeTotal); 
////////////////写标题//////////////////////////// 
	CRect rc; 
	GetClientRect(&rc); 
	pDC->SetTextAlign(TA_CENTER); 
	pDC->TextOut(rc.CenterPoint().x,10,"轻轻松松查单词"); 
	pDC->SetTextAlign(TA_LEFT); 
////////////////////////////////////////////////// 
	POSITION po=notelist.GetHeadPosition(); 
	for(int i=1;i<=(notelist.GetCount()/2);i++) 
	{ 
		CString str=notelist.GetNext(po); 
		pDC->TextOut(0,(i)*45,str); 
		str=notelist.GetNext(po); 
		pDC->TextOut(0,(i)*45+20,str); 
		pDC->MoveTo(0,i*45); 
		pDC->LineTo(1024,i*45); 
	} 
} 
 
 
void CTriumphView::OnInitialUpdate() 
{ 
	CScrollView::OnInitialUpdate(); 
	CSize sizeTotal; 
	sizeTotal.cx = 100; 
	sizeTotal.cy = 100; 
	SetScrollSizes(MM_TEXT, sizeTotal); 
 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CTriumphView diagnostics 
 
#ifdef _DEBUG 
void CTriumphView::AssertValid() const 
{ 
	CScrollView::AssertValid(); 
} 
 
void CTriumphView::Dump(CDumpContext& dc) const 
{ 
	CScrollView::Dump(dc); 
} 
 
CTriumphDoc* CTriumphView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTriumphDoc))); 
	return (CTriumphDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CTriumphView message handlers 
 
void CTriumphView::TextOut(CDC * pDC,int x, int y, NOTESTRUCT ns) 
{ 
	if(ns.WordLength==0)  
	{ 
		pDC->TextOut(x,y,ns.Word+" 找不到!"); 
	} 
	else  
	{ 
		pDC->TextOut(x,y,ns.Word+"   "+ns.Phonetic); 
		pDC->TextOut(x,y+20,ns.Explanation); 
	} 
} 
 
BOOL CTriumphView::HaveDirectary(CString dir) 
{ 
	HANDLE hPath = CreateFile( "MuLu", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL ); 
	if( hPath == INVALID_HANDLE_VALUE ) 
	{ 
	//目录不存在 
		return FALSE;  
	} 
	else 
		return TRUE;  
}