www.pudn.com > scrnsaverTY23.zip > MatrixString.cpp


// MatrixString.cpp: implementation of the CMatrixString class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "MatrixString.h" 
#include "constants.h" 
#include "Matrix.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
LPCTSTR CMatrixString::m_pData = "¦¡¦¢¦£¦¤¦¥¦¦¦§¦¨¦©¦ª¦«¦¬¦­¦®¦¯¦°¦±¦²¦³¦´¦µ¦¶¦·¦¸" 
				"¦Á¦Â¦Ã¦Ä¦Å¦Æ¦Ç¦È¦É¦Ê¦Ë¦Ì¦Í¦Î¦Ï¦Ð¦Ñ¦Ò¦Ó¦Ô¦Õ¦Ö¦×¦Ø" 
				"1234567890abcdefghijklmnopqrstuvwxzy" 
				"ABCDEFGHIJKLMNOPQRSTUVWXZY"; 
int CMatrixString::m_nDataLen = strlen(m_pData);	//±ØÎªÅ¼Êý 
 
CMatrixString::CMatrixString() 
{ 
	int k; 
	int nLen = rand() % STR_MAX_LEN; 
	int nPos; 
 
	 
	for (k = 0; k < nLen; k += 2) { 
		nPos = rand() % (m_nDataLen - 2); 
		if (nPos % 2) 
			nPos++; 
		m_strMatrix += CString(m_pData[nPos]) + CString(m_pData[nPos + 1]);	 
	} 
	nLen = rand() % STR_BLANK_TAIL; 
	if (nLen < STR_MIN_TAIL) 
		nLen = STR_MIN_TAIL; 
	if (nLen % 2)		//ÆæÊý 
		nLen++; 
	for (k = 0; k < nLen; k++) 
		m_strMatrix += CString(" "); 
	 
	m_nLen = 0; 
} 
 
CMatrixString::~CMatrixString() 
{ 
 
} 
 
CString CMatrixString::GetString() 
{ 
	return m_strMatrix; 
} 
 
int CMatrixString::GetLength(CDC *pDC) 
{ 
	if (m_nLen == 0) { 
		pDC->SelectObject(theMatrix.GetFont()); 
		CSize sz = pDC->GetTextExtent(m_strMatrix); 
		m_nLen = sz.cx; 
	} 
	return m_nLen; 
 
}