📄 ddstring.cpp
字号:
#include "stdafx.h"
#include "resource.h"
#include "define.h"
#include "DDString.h"
/////////////////////////////////////////////////////////////////
CDDString::CDDString()
{
m_bActive=true;
m_nNumber=0;
//m_cWords="\0";//NULL;
m_nLength=0;
}
////////////////////////////////////////////////////////////////////////////////////
CDDString::CDDString(int nNumber,int nLength,RECT rect)
{
m_bActive=true;
m_nNumber=nNumber;
m_nLength=nLength;
m_rcSource=rect;
m_nHeight=rect.bottom-rect.top+1;
m_nWidth=rect.right-rect.left+1;
}
/////////////////////////////////////////////////////////////////////////////////////////
//
void CDDString::Initialize(int nX,int nY,int nLength,int nSpace,RECT rect)
{
m_nLength=nLength;
m_nSpace=nSpace;
SetSource(rect);
SetShowPosition(nX,nY);
for(int i=0;i<m_nLength;i++)
{
int nDelta=10+26;
m_rcSourceArray[i].left =m_rcSource.left+m_nWidth*nDelta;
m_rcSourceArray[i].right =m_rcSourceArray[i].left+m_nWidth-1;
m_rcSourceArray[i].top =m_rcSource.top;
m_rcSourceArray[i].bottom =m_rcSourceArray[i].top+m_nHeight-1;
}
return;
}
///////////////////////////////////////////////////////////////////////////////////
//
void CDDString::SetShowPosition(int nX,int nY)
{
m_nX=nX;
m_nY=nY;
for(int i=0;i<m_nLength;i++)
{
m_nXArray[i]=m_nX+(m_nWidth+m_nSpace)*i;
}
}
///////////////////////////////////////////////////////////////////////////////////
//
void CDDString::SetSource(RECT rect)
{
m_rcSource=rect;
m_nHeight=rect.bottom-rect.top+1;
m_nWidth=rect.right-rect.left+1;
return;
}
//////////////////////////////////////////////////////////////////////
void CDDString::SetRect(int nPosition,int nWords)
{
if(nPosition<m_nLength&&nPosition>=0)
{
m_rcSourceArray[nPosition].left=m_rcSource.left+m_nWidth*nWords;
m_rcSourceArray[nPosition].right=m_rcSourceArray[nPosition].left+m_nWidth-1;
m_rcSourceArray[nPosition].top=m_rcSource.top;
m_rcSourceArray[nPosition].bottom=m_rcSourceArray[nPosition].top+m_nHeight-1;
//*
char cTemp=(char)nWords-10+65;
int nLength=m_cWords.GetLength();
if(nPosition>nLength-1)
{
for(int i=nLength;i<m_nLength;i++)
{
if(i!=nPosition)m_cWords+=' ';
else m_cWords+=cTemp;
}
}
else
m_cWords.SetAt(nPosition,cTemp);
//*/
}
return;
}
/////////////////////////////////////////////////////////////////
bool CDDString::ArrangeRect(int nNumber)
{
int nTemp1,nTemp2,nDelta;
m_nNumber=nNumber;
nTemp1=m_nNumber;
for(int i=m_nLength-1;i>-1;i--)
{
nTemp2=nTemp1/10;
nDelta=nTemp1-nTemp2*10;
nTemp1=nTemp2;
m_rcSourceArray[i].left=m_rcSource.left+m_nWidth*nDelta;
m_rcSourceArray[i].right=m_rcSourceArray[i].left+m_nWidth-1;
m_rcSourceArray[i].top=m_rcSource.top;
m_rcSourceArray[i].bottom=m_rcSourceArray[i].top+m_nHeight-1;
}
return true;
}
/////////////////////////////////////////////////////////////////////////
//
bool CDDString::ArrangeRect(CString cWords)
{
int nDelta;
m_cWords=cWords;
for(int i=0;i<m_nLength;i++)
{
//if(m_cWords[i]!='\0')//为什么这样写在WIN98下VC5编译后运行即非法?
if(i<m_cWords.GetLength())
{
nDelta=(int)(m_cWords[i]);
//if(nDelta>90)nDelta-=26;//将小写字母统一为大写;
nDelta=nDelta-65+10;
if(nDelta<0||nDelta>38)nDelta=38;
}
else//字符串结束了,将后面空白处填满;
{
nDelta=38;
}
m_rcSourceArray[i].left=m_rcSource.left+m_nWidth*nDelta;
m_rcSourceArray[i].right=m_rcSourceArray[i].left+m_nWidth-1;
m_rcSourceArray[i].top=m_rcSource.top;
m_rcSourceArray[i].bottom=m_rcSourceArray[i].top+m_nHeight-1;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
bool CDDString::Show(CDD *pDD)
{
if(m_bActive)
for(int i=0;i<m_nLength;i++)
if(!pDD->BlitSourceToBack(m_nXArray[i],
m_nY,
m_rcSourceArray[i],
DDBLTFAST_SRCCOLORKEY))return false;
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -