两张bmp叠加

1,将CreditStatic.h CreditStatic.cpp文件增加到工程目录下,并加到程序中

//创建24位bmp区域

在客商区画直线等图形时,
开掘当其最小化或然其余窗口遮挡时,出现窗口重绘,而将原本绘制的图样删除,上网络查找知道,绘制图形的代码必需放置在Ondraw函数中,本事幸免重绘时图形消失(因为一贯在响应WM_PAINT音讯,不断的重绘),可是如此做却不能不保留方今的二遍绘图,只适用于单幅固定的图样,对于内部有多幅图片就不能那样做了,解决的思绪是:思考到MFC时
文档/视图
类,视图CView担当数据的显得和改造,文书档案CDocument类负担数据的储存和加载,进而把数据管理和出示方式分别开来。大家在CDocument类中增多一个CBitMap对象,将每趟中间绘图时的顾客区的原委保留成BitMap,当有着的操作都实行好以后,将最后的BitMap拷贝到荧屏中,那便是所谓的内部存款和储蓄器缓存画图情势。这么做还或许有一个功利便是改良是看不到闪烁。

2,在相应的对话框中加多变量:CCreditStatic m_static;

HBITMAP CreateBitmapSection(HDC hdc,int cx,int cy,BYTE** ppbit)

实际代码如下:

3,在对应的对话框中增进静态文本,并改过其ID为:IDC_DISPLAY_STATIC

{

1、中间图形管理进度(事情发生在此以前已经在CDrawDoc类中增添了变量CBitmap
m_bmpBuf;):

4,在相应的对话框的OnInitDialog函数中增加代码如下:

BITMAPINFO bmi ;

void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
 CDC *pDC = GetDC();
 CDrawDoc *pDoc = GetDocument();
 CDC dcMem;

m_static.SubclassDlgItem(IDC_DISPLAY_STATIC,this);

memset(&bmi.bmiHeader, 0, sizeof(BITMAPINFOHEADER));

dcMem.CreateCompatibleDC(NULL);
 CRect rect;
 GetClientRect(&rect卡塔尔; //获取顾客区域
 pDoc->m_bmpBuf.DeleteObject();
 pDoc->m_bmpBuf.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
 CBitmap *pOldBitmap =
dcMem.SelectObject(&pDoc->m_bmpBuf卡塔尔国;//将创设好的m_bmpBuf增多到临时的CDC的Object中,相近于在墙上先糊上墙纸^_^,先在墙纸上描绘,最终将最后产生的画拷贝到墙上。
 m_ptEnd = point;

m_static.SetBkImage(IDB_BITMAP1);

bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER) ;

 dcMem.BitBlt(0,0,rect.Width(),rect.Height(),pDC,0,0,SRCCOPY);

m_static.SetCredits(pArrCredit,|);

bmi.bmiHeader.biPlanes = 1;

 dcMem.SelectObject(pOldBitmap卡塔尔国;
//将pDC即当前用户区里面包车型地铁从头到尾的经过拷贝到有的时候的MEM中,MEM就算之后会被delete掉,不过它纠正了CDocument类中的m_bmpBuf
 m_bDraw = false;
 dcMem.DeleteDC();
}

m_static.SetSpeed(1);

bmi.bmiHeader.biBitCount = 24;

2、最终展现(在OnDraw中得以达成卡塔尔:

m_static.SetColor(BACKGROUND_COLOR, RGB(0,0,0));

bmi.bmiHeader.biCompression = BI_RGB;

void CDrawView::OnDraw(CDC* pDC)
{
 CDrawDoc* pDoc = GetDocument();
 ASSERT_VALID(pDoc);
 if (!pDoc)
  return;
 CRect rect;
 GetClientRect(&rect);
 CDC dcMem;//以下是出口位图的正式操作
 CBitmap *pOldBitmap = NULL;
 dcMem.CreateCompatibleDC(NULL);
 pOldBitmap = dcMem.SelectObject(&pDoc->m_bmpBuf);
 
 pDC->BitBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,SRCCOPY);
 dcMem.SelectObject(pOldBitmap卡塔尔(قطر‎; //将dcMeM中的bitmap拷贝到日前客商区
 dcMem.DeleteDC();

m_static.SetTransparent();

bmi.bmiHeader.biWidth = cx;

}

m_static.StartScrolling();

bmi.bmiHeader.biHeight = cy;

 

其中::pArrCredit为char*花色,里边放要彰显的字幕,在对应对话框的CDlg中扬言并开始化,如::

return
CreateDIBSection(hdc,&bmi,DIB_RGB_COLORS,(void**)ppbit,NULL,0);

char *pArrCredit = { ¸多谢你||购买本书||

}

本书会令你受益良多||本书小编||

//叠加两张bmp图片并出口到制订DC,Alpha取值范围
0~255(0为全透明,255为不透明卡塔尔

BITMAP1^|||

void TransParentPicture(CDC *pDC, HBITMAP hOneBitmap, HBITMAP
hTwoBitmap, CRect ClientRect,int Alpha)

};

{

[plain]view plaincopyprint?

BITMAP
OneBitmap;

1.CreditStatic.cpp的代码:

BITMAP
TwoBitmap;

//CreditStatic.cpp:implementationfile

GetObject(hOneBitmap, sizeof(BITMAP), &OneBitmap);

//

GetObject(hTwoBitmap, sizeof(BITMAP), &TwoBitmap);

#includestdafx.h

int
nOneImageWidth = OneBitmap.bmWidth;

#includeCreditStatic.h

int
nOneImageHeight = OneBitmap.bmHeight;

#ifdef_DEBUG

int
nTwoImageWidth = TwoBitmap.bmWidth;

#definenewDEBUG_NEW

int
nTwoImageHeight = TwoBitmap.bmHeight;

#undefTHIS_FILE

if
(nOneImageWidth < nTwoImageWidth)

staticcharTHIS_FILE[]=__FILE__;

{

#endif

nOneImageWidth = nTwoImageWidth;

#defineDISPLAY_TIMER_ID150//timerid

}  

/////////////////////////////////////////////////////////////////////////////

else

//CCreditStatic

{

CCreditStatic::CCreditStatic()

nTwoImageWidth = nOneImageWidth;

{

}

m_Colors[0]=RGB(0,0,0);//Black

if
(nOneImageHeight < nTwoImageHeight)

m_Colors[1]=RGB(255,0,0);//Red

{

m_Colors[2]=RGB(255,255,0);//Yellow

nOneImageHeight = nTwoImageHeight;

m_Colors[3]=RGB(0,255,255);//Turquoise

}

m_Colors[4]=RGB(255,255,255);//White

else

m_TextHeights[0]=21;

{

m_TextHeights[1]=19;

nTwoImageHeight = nOneImageHeight;

m_TextHeights[2]=17;

}

m_TextHeights[3]=15;

int
nImageWidth = nOneImageWidth;

m_nCurrentFontHeight=m_TextHeights[NORMAL_TEXT_HEIGHT];

int
nImageHeight = nOneImageHeight;

m_Escapes[0]=t;

CDC
MemDC1, MemDC2;

m_Escapes[1]=n;

HBITMAP
hOldBitmap1 = NULL, hOldBitmap2 = NULL;

m_Escapes[2]=r;

BYTE
*pOneBits = NULL;

m_Escapes[3]=^;

MemDC1.CreateCompatibleDC(pDC);

m_DisplaySpeed[0]=70;

MemDC2.CreateCompatibleDC(pDC);

m_DisplaySpeed[1]=40;

HBITMAP
hOneBmp = NULL;

m_DisplaySpeed[2]=10;

hOneBmp =
CreateBitmapSection(pDC->m_hDC, nImageWidth, nImageHeight,
&pOneBits);

m_CurrentSpeed=1;

hOldBitmap1 = (HBITMAP)SelectObject(MemDC1.m_hDC, hOneBmp);

m_ScrollAmount=-1;

hOldBitmap2 = (HBITMAP)SelectObject(MemDC2.m_hDC, hOneBitmap);

m_bProcessingBitmap=FALSE;

//BitBlt(MemDC1.m_hDC, 0, 0, m_nTwoImage_w, m_nTwoImage_h,
MemDC2.m_hDC, 0, 0, SRCCOPY);

m_ArrIndex=NULL;

StretchBlt(MemDC1.m_hDC, 0, 0, nImageWidth, nImageHeight,

m_nCounter=1;

MemDC2.m_hDC, 0, 0, OneBitmap.bmWidth, OneBitmap.bmHeight,
SRCCOPY);

m_nClip=0;

CDC
MemDC3, MemDC4;

m_bFirstTime=TRUE;

HBITMAP
hOldBitmap3 = NULL, hOldBitmap4 = NULL;

m_bDrawText=FALSE;

BYTE
*pTwoBits = NULL;

m_bFirstTurn=TRUE;

MemDC3.CreateCompatibleDC(pDC);

m_Gradient=GRADIENT_NONE;

MemDC4.CreateCompatibleDC(pDC);

m_bTransparent=FALSE;

HBITMAP
hTwoBmp = NULL;

n_MaxWidth=0;

hTwoBmp =
CreateBitmapSection(pDC->m_hDC, nImageWidth, nImageHeight,
&pTwoBits);

TimerOn=0;

hOldBitmap3 = (HBITMAP)SelectObject(MemDC3.m_hDC, hTwoBmp);

}

hOldBitmap4 = (HBITMAP)SelectObject(MemDC4.m_hDC, hTwoBitmap);

CCreditStatic::~CCreditStatic()

//BitBlt(MemDC3.m_hDC, 0, 0, m_nTwoImage_w, m_nTwoImage_h,
MemDC4.m_hDC, 0, 0, SRCCOPY);

{

StretchBlt(MemDC3.m_hDC, 0, 0, nImageWidth, nImageHeight,

}

MemDC4.m_hDC, 0, 0, TwoBitmap.bmWidth, TwoBitmap.bmHeight,
SRCCOPY);

BEGIN_MESSAGE_MAP(CCreditStatic,CStatic)

CDC
MemDC5;

//{{AFX_MSG_MAP(CCreditStatic)

HBITMAP
hOldBitmap5 = NULL;

ON_WM_PAINT()

BYTE*
pNewBits=NULL;

ON_WM_ERASEBKGND()

MemDC5.CreateCompatibleDC(pDC);

ON_WM_TIMER()

HBITMAP
hNewBitmap = NULL;

ON_WM_DESTROY()

hNewBitmap = CreateBitmapSection(pDC->m_hDC, nImageWidth,
nImageHeight, &pNewBits);

//}}AFX_MSG_MAP

hOldBitmap5 = (HBITMAP)SelectObject(MemDC5.m_hDC, hNewBitmap);

END_MESSAGE_MAP()

int
linebytes=0;

/////////////////////////////////////////////////////////////////////////////

int
col=0;

//CCreditStaticmessagehandlers

int
line=(((nImageWidth*24)+31)>>5)<<2;

BOOLCCreditStatic::StartScrolling()

linebytes
= line;

{

col =
nImageHeight;

//滚动字符为空,再次回到

for(int
j=0;j<col;j++)

if(m_ArrCredit.IsEmpty())

{

returnFALSE;

for(int
i=0;i<linebytes;i++)

if(m_BmpMain.m_hObject!=NULL){

{

m_BmpMain.DeleteObject();

*(pNewBits + j*line + i)=(*(pOneBits + j*line + i)*Alpha +

m_BmpMain.m_hObject=NULL;

*(pTwoBits+j*line+i)*(255-Alpha))/255;

}

}

//设置准时期隔

}

TimerOn=SetTimer(DISPLAY_TIMER_ID,m_DisplaySpeed[m_CurrentSpeed],NULL);

BitBlt(pDC->m_hDC, 0, 0, ClientRect.Width(),
ClientRect.Height(), MemDC5.m_hDC, 0, 0, SRCCOPY);

ASSERT(TimerOn!=0);

//StretchBlt(pDC->m_hDC, 0, 0, m_ClientRect.Width(),
m_ClientRect.Height(),

m_ArrIndex=m_ArrCredit.GetHeadPosition();

// MemDC5.m_hDC,
0, 0, m_nOneImage_w, m_nOneImage_h, SRCCOPY);

m_nCounter=1;

SelectObject(MemDC5.m_hDC,hOldBitmap5);

m_nClip=0;

MemDC5.DeleteDC();

m_bFirstTime=TRUE;

SelectObject(MemDC4.m_hDC,hOldBitmap4);

m_bDrawText=FALSE;

MemDC4.DeleteDC();

returnTRUE;

SelectObject(MemDC3.m_hDC,hOldBitmap3);

}

MemDC3.DeleteDC();

//结束滚动

SelectObject(MemDC2.m_hDC,hOldBitmap2);

voidCCreditStatic::EndScrolling()

MemDC2.DeleteDC();

{

SelectObject(MemDC1.m_hDC,hOldBitmap1);

//甘休按时

MemDC1.DeleteDC();

KillTimer(DISPLAY_TIMER_ID);

}

TimerOn=0;

if(m_BmpMain.m_hObject!=NULL){

m_BmpMain.DeleteObject();

m_BmpMain.m_hObject=NULL;

}

}

//获得分开的字符串,用来滚动呈现

voidCCreditStatic::SetCredits(LPCTSTRcredits,chardelimiter)

{

char*str,*ptr1,*ptr2;

ASSERT(credits);

if((str=strdup(credits))==NULL)

return;

m_ArrCredit.RemoveAll();

ptr1=str;

//得到分开的字符串,个中/表示行与行以内的间距

while((ptr2=strchr(ptr1,delimiter))!=NULL){

*ptr2=;

m_ArrCredit.AddTail(ptr1);

ptr1=ptr2+1;

}

m_ArrCredit.AddTail(ptr1);

free(str);

m_ArrIndex=m_ArrCredit.GetHeadPosition();

m_nCounter=1;

m_nClip=0;

m_bFirstTime=TRUE;

m_bDrawText=FALSE;

}

voidCCreditStatic::SetCredits(UINTnID,chardelimiter)

{

CStringcredits;

if(!credits.LoadString(nID))

return;

SetCredits((LPCTSTR)credits,delimiter);

}

//设置滚动速度

voidCCreditStatic::SetSpeed(UINTindex,intspeed)

{

ASSERT(index=DISPLAY_FAST);

if(speed)

m_DisplaySpeed[index]=speed;

m_CurrentSpeed=index;

}

//设置颜色,包含前途和背景

voidCCreditStatic::SetColor(UINTindex,COLORREFcol)

{

ASSERT(index=NORMAL_TEXT_COLOR);

m_Colors[index]=col;

}

//设置字符中度

voidCCreditStatic::SetTextHeight(UINTindex,intheight)

{

ASSERT(index=NORMAL_TEXT_HEIGHT);

m_TextHeights[index]=height;

}

voidCCreditStatic::SetEscape(UINTindex,charescape)

{

ASSERT(index=DISPLAY_BITMAP);

m_Escapes[index]=escape;

}

voidCCreditStatic::SetGradient(UINTvalue)

{

ASSERT(value=GRADIENT_LEFT_LIGHT);

m_Gradient=value;

}

//设置是不是透明

voidCCreditStatic::SetTransparent(BOOLbTransparent)

{

m_bTransparent=bTransparent;

}

voidCCreditStatic::OnPaint()

{

CPaintDCdc(this);//devicecontextforpainting

if(TimerOn)return;

CDCmemDC;

memDC.CreateCompatibleDC(dc);

CBitmap*pOldMemDCBitmap=NULL;

CRectm_ScrollRect;

GetClientRect(m_ScrollRect);

if(m_BmpMain.m_hObject==NULL){

CDCmemDC2;

CBitmapbitmap;

memDC2.CreateCompatibleDC(dc);

bitmap.CreateCompatibleBitmap(dc,m_ScrollRect.Width(),m_ScrollRect.Height());

CBitmap*pOldMemDC2Bitmap=(CBitmap*)memDC2.SelectObject(bitmap);

DrawCredit(memDC2,m_ScrollRect);

AddBackGround(memDC2,m_ScrollRect,m_ScrollRect);

pOldMemDCBitmap=(CBitmap*)memDC.SelectObject(m_BmpMain);

memDC.BitBlt(0,0,m_ScrollRect.Width(),m_ScrollRect.Height(),

memDC2,0,0,SRCCOPY);

memDC2.SelectObject(pOldMemDC2Bitmap);

}

else

pOldMemDCBitmap=(CBitmap*)memDC.SelectObject(m_BmpMain);

dc.BitBlt(0,0,m_ScrollRect.Width(),m_ScrollRect.Height(),

memDC,0,0,SRCCOPY);

}

BOOLCCreditStatic::OnEraseBkgnd(CDC*pDC)

{

returnTRUE;

//returnCStatic::OnEraseBkgnd(pDC);

}

//************************************************************************

//OnTimer

//

//Oneachofthedisplaytimers,scrollthewindow1unit.Each20

//units,fetchthenextarrayelementandloadintoworkstring.Call

//InvalidateandUpdateWindowtoinvoketheOnPaintwhichwillpaint

//thecontentsofthenewlyupdatedworkstring.

//************************************************************************

voidCCreditStatic::OnTimer(UINTnIDEvent)

{

//非设置的机械漏刻ID,重回

if(nIDEvent!=DISPLAY_TIMER_ID)

{

CStatic::OnTimer(nIDEvent);

return;

}

BOOLbCheck=FALSE;

//假诺上次读入的字符串表示的不是位图名字

if(!m_bProcessingBitmap){

//根据m_nCurrentFontHeight中度决定要求多少次time响应才换一行字符展现

if(m_nCounter++%m_nCurrentFontHeight==0)

{

m_nCounter=1;

//读出字符串队列中下一行要出示的字符串

m_szWork=m_ArrCredit.GetNext(m_ArrIndex);

if(m_bFirstTurn)

bCheck=TRUE;

if(m_ArrIndex==NULL){

m_bFirstTurn=FALSE;

m_ArrIndex=m_ArrCredit.GetHeadPosition();

}

m_nClip=0;

m_bDrawText=TRUE;

}

}

CClientDCdc(this);

CRectm_ScrollRect;

GetClientRect(m_ScrollRect卡塔尔;//获得全数CStatic的顾客区坐标

CRectm_ClientRect(m_ScrollRect卡塔尔;//用来代表滚动字符的界定

m_ClientRect.left=(m_ClientRect.Width()-n_MaxWidth)/2;

m_ClientRect.right=m_ClientRect.left+n_MaxWidth;

MoveCredit(dc,m_ScrollRect,m_ClientRect,bCheck卡塔尔;//达成字幕滚动1单元

AddBackGround(dc,m_ScrollRect,m_ClientRectState of Qatar;//增加背景

CStatic::OnTimer(nIDEvent);

}

//设置背景

voidCCreditStatic::AddBackGround(CDC*pDC,CRectm_ScrollRect,CRectm_ClientRect)

{

CDCmemDC;

memDC.CreateCompatibleDC(pDC);

if(m_bitmap.m_hObject==NULL)

{

CBitmap*pOldBitmap=memDC.SelectObject(m_BmpMain);

pDC-BitBlt(0,0,m_ScrollRect.Width(),m_ScrollRect.Height(),

memDC,0,0,SRCCOPY);

memDC.SelectObject(pOldBitmap);

return;

}

//Drawbitmapinthebackgroundifonehasbeenset

//Nowcreateamask

CBitmapbitmap;

bitmap.CreateCompatibleBitmap(pDC,m_ClientRect.Width(),m_ClientRect.Height());

CBitmap*pOldMemDCBitmap=memDC.SelectObject(bitmap);

CDCtempDC;

tempDC.CreateCompatibleDC(pDC);

CBitmap*pOldTempDCBitmap=tempDC.SelectObject(m_BmpMain);

memDC.BitBlt(0,0,m_ClientRect.Width(),m_ClientRect.Height(),tempDC,

m_ClientRect.left,m_ClientRect.top,SRCCOPY);

CDCmaskDC;

maskDC.CreateCompatibleDC(pDC);

CBitmapmaskBitmap;

//Createmonochromebitmapforthemask

maskBitmap.CreateBitmap(m_ClientRect.Width(),m_ClientRect.Height(),1,1,NULL);

CBitmap*pOldMaskDCBitmap=maskDC.SelectObject(maskBitmap);

memDC.SetBkColor(m_bTransparent?RGB(192,192,192):m_Colors[BACKGROUND_COLOR]);

//CreatethemaskfromthememoryDC

maskDC.BitBlt(0,0,m_ClientRect.Width(),m_ClientRect.Height(),memDC,0,0,SRCCOPY);

tempDC.SelectObject(pOldTempDCBitmap);

pOldTempDCBitmap=tempDC.SelectObject(m_bitmap);

CDCimageDC;

CBitmapbmpImage;

imageDC.CreateCompatibleDC(pDC);

bmpImage.CreateCompatibleBitmap(pDC,m_ScrollRect.Width(),m_ScrollRect.Height());

CBitmap*pOldImageDCBitmap=imageDC.SelectObject(bmpImage);

if(pDC-GetDeviceCaps(RASTERCAPS)RC_PALETTEm_pal.m_hObject!=NULL)

{

pDC-SelectPalette(m_pal,FALSE);

pDC-RealizePalette();

imageDC.SelectPalette(m_pal,FALSE);

}

//Getxandyoffset

//DrawbitmapintiledmannertoimageDC

for(inti=0;im_ScrollRect.right;i+=m_cxBitmap)

for(intj=0;jm_ScrollRect.bottom;j+=m_cyBitmap)

imageDC.BitBlt(i,j,m_cxBitmap,m_cyBitmap,tempDC,0,0,SRCCOPY);

//SetthebackgroundinmemDCtoblack.UsingSRCPAINTwithblackandanyother

//colorresultsintheothercolor,thusmakingblackthetransparentcolor

memDC.SetBkColor(RGB(0,0,0));

memDC.SetTextColor(RGB(255,255,255));

memDC.BitBlt(0,0,m_ClientRect.Width(),m_ClientRect.Height(),maskDC,0,0,SRCAND);

//Settheforegroundtoblack.Seecommentabove.

imageDC.SetBkColor(RGB(255,255,255));

imageDC.SetTextColor(RGB(0,0,0));

imageDC.BitBlt(m_ClientRect.left,m_ClientRect.top,m_ClientRect.Width(),m_ClientRect.Height(),

maskDC,0,0,SRCAND);

//Combinetheforegroundwiththebackground

imageDC.BitBlt(m_ClientRect.left,m_ClientRect.top,m_ClientRect.Width(),m_ClientRect.Height(),

memDC,0,0,SRCPAINT);

//Drawthefinalimagetothescreen

pDC-BitBlt(0,0,m_ScrollRect.Width(),m_ScrollRect.Height(),

imageDC,0,0,SRCCOPY);

imageDC.SelectObject(pOldImageDCBitmap);

maskDC.SelectObject(pOldMaskDCBitmap);

tempDC.SelectObject(pOldTempDCBitmap);

memDC.SelectObject(pOldMemDCBitmap);

}

voidCCreditStatic::DrawBitmap(CDC*pDC,CDC*pDC2,CRect*rBitmap)

{

if(!m_bTransparent||m_bitmap.m_hObject!=NULL){

pDC-BitBlt(rBitmap-left,rBitmap-top,rBitmap-Width(),rBitmap-Height(),

pDC2,0,0,SRCCOPY);

return;

}

//制造与pDC宽容的设施

CDCmemDC;

memDC.CreateCompatibleDC(pDC);

//创立包容位图况兼选进设备

CBitmapbitmap;

bitmap.CreateCompatibleBitmap(pDC,rBitmap-Width(),rBitmap-Height());

CBitmap*pOldMemDCBitmap=memDC.SelectObject(bitmap);

//将pDC第22中学的位图拷贝到memDC

memDC.BitBlt(0,0,rBitmap-Width(),rBitmap-Height(),pDC2,0,0,SRCCOPY);

CDCmaskDC;

maskDC.CreateCompatibleDC(pDC);

//创建单色位图並且选入设备

CBitmapmaskBitmap;

maskBitmap.CreateBitmap(rBitmap-Width(),rBitmap-Height(),1,1,NULL);

CBitmap*pOldMaskDCBitmap=maskDC.SelectObject(maskBitmap);

memDC.SetBkColor(V12 VantageGB(192,192,192State of QatarState of Qatar;//背景为系统色

//将memDC中的位图拷贝到maskDC,maskDC中的的1象征位图背景象,0代表前途,即位图

maskDC.BitBlt(0,0,rBitmap-Width(),rBitmap-Height(),memDC,0,0,SRCCOPY);

CDCimageDC;

CBitmapbmpImage;

imageDC.CreateCompatibleDC(pDC);

bmpImage.CreateCompatibleBitmap(pDC,rBitmap-Width(),rBitmap-Height());

CBitmap*pOldImageDCBitmap=imageDC.SelectObject(bmpImage);

//将pDC中对应位图背景区域拷贝到imageDC

imageDC.BitBlt(0,0,rBitmap-Width(),rBitmap-Height(),pDC,rBitmap-left,rBitmap-top,SRCCOPY);

//下边的代码达成透明位图,见msdn的DrawingTransparentBitmaps

//SetthebackgroundinmemDCtoblack.UsingSRCPAINTwithblackandanyother

//colorresultsintheothercolor,thusmakingblackthetransparentcolor

//设置背景为浅橙

memDC.SetBkColor(RGB(0,0,0));

memDC.SetTextColor(RGB(255,255,255));

memDC.BitBlt(0,0,rBitmap-Width(),rBitmap-Height(),maskDC,0,0,SRCAND);

//设置前程为中湖蓝

imageDC.SetBkColor(RGB(255,255,255));

imageDC.SetTextColor(RGB(0,0,0));

imageDC.BitBlt(0,0,rBitmap-Width(),rBitmap-Height(),maskDC,0,0,SRCAND);

//得到透明的位图

imageDC.BitBlt(0,0,rBitmap-Width(),rBitmap-Height(),memDC,0,0,SRCPAINT);

//将位图移动到适当岗位

pDC-BitBlt(rBitmap-left,rBitmap-top,rBitmap-Width(),rBitmap-Height(),

imageDC,0,0,SRCCOPY);

imageDC.SelectObject(pOldImageDCBitmap);

maskDC.SelectObject(pOldMaskDCBitmap);

memDC.SelectObject(pOldMemDCBitmap);

}

voidCCreditStatic::FillGradient(CDC*pDC,CRect*m_ScrollRect,CRect*m_FillRect,COLORREFcolor)

{

floatfStep,fRStep,fGStep,fBStep;//Howlargeiseachband?

intiOnBand;//Loopindex

WORDR=GetRValue(color);

WORDG=GetGValue(color);

WORDB=GetBValue(color);

//Determinehowlargeeachbandshouldbeinordertocoverthe

//clientwith256bands(oneforeverycolorintensitylevel)

if(m_Gradient%2){

fRStep=(float)R/255.0f;

fGStep=(float)G/255.0f;

fBStep=(float)B/255.0f;

}else{

fRStep=(float)(255-R)/255.0f;

fGStep=(float)(255-G)/255.0f;

fBStep=(float)(255-B)/255.0f;

}

COLORREFOldCol=pDC-GetBkColor();

//Startfillingbands

fStep=(float)m_ScrollRect-Width()/256.0f;

for(iOnBand=(256*m_FillRect-left)/m_ScrollRect-Width();

(int)(iOnBand*fStep)m_FillRect-rightiOnBand256;iOnBand++){

CRectr((int)(iOnBand*fStep),m_FillRect-top,

(int)((iOnBand+1)*fStep),m_FillRect-bottom+1);

COLORREFcol;

switch(m_Gradient){

caseGRADIENT_RIGHT_DARK:

col=RGB((int)(R-iOnBand*fRStep),(int)(G-iOnBand*fGStep),(int)(B-iOnBand*fBStep));

break;

caseGRADIENT_RIGHT_LIGHT:

col=RGB((int)(R+iOnBand*fRStep),(int)(G+iOnBand*fGStep),(int)(B+iOnBand*fBStep));

break;

caseGRADIENT_LEFT_DARK:

col=RGB((int)(iOnBand*fRStep),(int)(iOnBand*fGStep),(int)(iOnBand*fBStep));

break;

caseGRADIENT_LEFT_LIGHT:

col=RGB(255-(int)(iOnBand*fRStep),255-(int)(iOnBand*fGStep),255-(int)(iOnBand*fBStep));

break;

default:

return;

}

pDC-FillSolidRect(r,col);

}

pDC-SetBkColor(OldCol);

}

#defineSCROLLDC

voidCCreditStatic::MoveCredit(CDC*pDC,CRectm_ScrollRect,CRectm_ClientRect,BOOLbCheck)

{

CDCmemDC,memDC2;

//创建包容的装置

memDC.CreateCompatibleDC(pDC);

memDC2.CreateCompatibleDC(pDC);

//决定背景颜色,假使起初设置为透明何况有背景位图,就采纳系统色,不然选取设置的背景象

COLORREFBackColor=(m_bTransparentm_bitmap.m_hObject!=NULL)?RGB(192,192,192):m_Colors[BACKGROUND_COLOR];

CBitmap*pOldMemDCBitmap=NULL;

CBitmap*pOldMemDC2Bitmap=NULL;

#ifdefSCROLLDC

CRectr1;

#endif

//起先句柄为空

if(m_BmpMain.m_hObject==NULL){

//创制与设备万分的位图

m_BmpMain.CreateCompatibleBitmap(pDC,m_ScrollRect.Width(),m_ScrollRect.Height());

//将位图选入设备

pOldMemDCBitmap=(CBitmap*)memDC.SelectObject(m_BmpMain);

//选用是用梯度依然背景观填充设备memDC的背景

if(m_Gradientm_bitmap.m_hObject==NULL)

FillGradient(memDC,m_ScrollRect,m_ScrollRect,m_Colors[BACKGROUND_COLOR]);

else

memDC.FillSolidRect(m_ScrollRect,BackColor);

}else

pOldMemDCBitmap=(CBitmap*)memDC.SelectObject(m_BmpMain);

if(m_ClientRect.Width()0){

#ifndefSCROLLDC//假如不援救器具滚动

CBitmapbitmap;

bitmap.CreateCompatibleBitmap(pDC,m_ClientRect.Width(),m_ClientRect.Height());

pOldMemDC2Bitmap=memDC2.SelectObject(bitmap);

//memDC向上滚动一行,利用设备拷贝

memDC2.BitBlt(0,0,m_ClientRect.Width(),m_ClientRect.Height()-abs(m_ScrollAmount),

memDC,m_ClientRect.left,abs(m_ScrollAmount),SRCCOPY);

memDC.BitBlt(m_ClientRect.left,0,m_ClientRect.Width(),m_ClientRect.Height(),

memDC2,0,0,SRCCOPY);

memDC2.SelectObject(pOldMemDC2Bitmap);

pOldMemDC2Bitmap=NULL;

#else//假如帮助设施滚动

CRgnRgnUpdate;

//memDC向上滚动一行,利用设备拷贝

memDC.ScrollDC(0,m_ScrollAmount,(LPCRECT)m_ScrollRect,(LPCRECT)m_ClientRect,RgnUpdate,

(LPRECT)r1);

}

else{

//r1存款和储蓄着要更新的区域地方

r1=m_ScrollRect;

r1.top=r1.bottom-abs(m_ScrollAmount);

#endif

}

m_nClip=m_nClip+abs(m_ScrollAmount);

//*********************************************************************

//FONTSELECTION

CFontm_fntArial;

CFont*pOldFont=NULL;

BOOLbSuccess=FALSE;

BOOLbUnderline;

BOOLbItalic;

intrmcode=0;

//依据字符串性质决定操作

//更新的显得字符串不为空

if(!m_szWork.IsEmpty()){

//依据字符串最终壹位决定项目

charc=m_szWork[m_szWork.GetLength()-1];

if(c==m_Escapes[TOP_LEVEL_GROUP]卡塔尔//类型为最大群组标题

{

rmcode=1;

bItalic=FALSE;

bUnderline=FALSE;

m_nCurrentFontHeight=m_TextHeights[TOP_LEVEL_GROUP_HEIGHT];

//创制字体

bSuccess=m_fntArial.CreateFont(m_TextHeights[TOP_LEVEL_GROUP_HEIGHT],0,0,0,

FW_BOLD,bItalic,bUnderline,0,

ANSI_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

PROOF_QUALITY,

VARIABLE_PITCH|0x04|FF_DONTCARE,

(LPSTR)Arial);

//设置字体颜色

memDC.SetTextColor(m_Colors[TOP_LEVEL_GROUP_COLOR]);

//选入设备

if(pOldFont!=NULL)memDC.SelectObject(pOldFont);

pOldFont=memDC.SelectObject(m_fntArial);

}

elseif(c==m_Escapes[GROUP_TITLE]State of Qatar{//类型为组标题

rmcode=1;

bItalic=FALSE;

bUnderline=FALSE;

m_nCurrentFontHeight=m_TextHeights[GROUP_TITLE_HEIGHT];

bSuccess=m_fntArial.CreateFont(m_TextHeights[GROUP_TITLE_HEIGHT],0,0,0,

FW_BOLD,bItalic,bUnderline,0,

ANSI_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

PROOF_QUALITY,

VARIABLE_PITCH|0x04|FF_DONTCARE,

(LPSTR)Arial);

memDC.SetTextColor(m_Colors[GROUP_TITLE_COLOR]);

if(pOldFont!=NULL)memDC.SelectObject(pOldFont);

pOldFont=memDC.SelectObject(m_fntArial);

}

elseif(c==m_Escapes[TOP_LEVEL_TITLE]卡塔尔国{//类型为最大标题

rmcode=1;

bItalic=FALSE;

//bUnderline=TRUE;

bUnderline=FALSE;

m_nCurrentFontHeight=m_TextHeights[TOP_LEVEL_TITLE_HEIGHT];

bSuccess=m_fntArial.CreateFont(m_TextHeights[TOP_LEVEL_TITLE_HEIGHT],0,0,0,

FW_BOLD,bItalic,bUnderline,0,

ANSI_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

PROOF_QUALITY,

VARIABLE_PITCH|0x04|FF_DONTCARE,

(LPSTR)Arial);

memDC.SetTextColor(m_Colors[TOP_LEVEL_TITLE_COLOR]);

if(pOldFont!=NULL)memDC.SelectObject(pOldFont);

pOldFont=memDC.SelectObject(m_fntArial);

}

elseif(c==m_Escapes[DISPLAY_BITMAP]State of Qatar{//类型为位图

if(!m_bProcessingBitmap)

{

CStringszBitmap=m_szWork.Left(m_szWork.GetLength(卡塔尔-1卡塔尔;//获得位图名字

if(m_bmpWork.LoadBitmap((constchar*卡塔尔(قطر‎szBitmap卡塔尔(قطر‎卡塔尔国{//载入位图

BITMAPm_bmpInfo;

m_bmpWork.GetObject(sizeof(BITMAP),m_bmpInfo);

m_size.cx=m_bmpInfo.bmWidth;//widthofdestrect

m_size.cy=m_bmpInfo.bmHeight;

//获得要体现位图的左上角坐标

m_pt.x=(m_ClientRect.right-

((m_ClientRect.Width())/2)-(m_size.cx/2));

m_pt.y=m_ClientRect.bottom;

m_bProcessingBitmap=TRUE;

if(pOldMemDC2Bitmap!=NULL)memDC2.SelectObject(pOldMemDC2Bitmap);

pOldMemDC2Bitmap=memDC2.SelectObject(m_bmpWork卡塔尔国;//位图选入设备memDC2

}

else

c=;

}

else{

if(pOldMemDC2Bitmap!=NULL)memDC2.SelectObject(pOldMemDC2Bitmap);

pOldMemDC2Bitmap=memDC2.SelectObject(m_bmpWork);

}

}

else{

bItalic=FALSE;

bUnderline=FALSE;

m_nCurrentFontHeight=m_TextHeights[NORMAL_TEXT_HEIGHT];

bSuccess=m_fntArial.CreateFont(m_TextHeights[NORMAL_TEXT_HEIGHT],0,0,0,

FW_THIN,bItalic,bUnderline,0,

ANSI_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

PROOF_QUALITY,

VARIABLE_PITCH|0x04|FF_DONTCARE,

(LPSTR)Arial);

memDC.SetTextColor(m_Colors[NORMAL_TEXT_COLOR]);

if(pOldFont!=NULL)memDC.SelectObject(pOldFont);

pOldFont=memDC.SelectObject(m_fntArial);

}

}

#ifndefSCROLLDC

CRectr1(m_ScrollRect);

r1.top=r1.bottom-abs(m_ScrollAmount);

#endif

//填充背景

if(m_Gradientm_bitmap.m_hObject==NULL)

FillGradient(memDC,m_ScrollRect,r1,m_Colors[BACKGROUND_COLOR]);

else

memDC.FillSolidRect(r1,BackColor);

memDC.SetBkMode(TRANSPARENT);

if(!m_bProcessingBitmap卡塔尔//倘诺不是位图

{

if(bCheck卡塔尔{//对于单身一行字符的第三回滚动,需求先鲜明滚动区域限量

CSizesize=memDC.GetTextExtent((LPCTSTR)m_szWork,m_szWork.GetLength()-rmcode);

if(size.cxn_MaxWidth){

n_MaxWidth=(size.cxm_ScrollRect.Width())?m_ScrollRect.Width():size.cx;

m_ClientRect.left=(m_ScrollRect.Width()-n_MaxWidth)/2;

m_ClientRect.right=m_ClientRect.left+n_MaxWidth;

}

}

CRectr(m_ClientRect);

r.top=r.bottom-m_nClip;

//在要立异的区域突显字符

intx=memDC.DrawText((constchar*)m_szWork,m_szWork.GetLength()-rmcode,r,DT_TOP|DT_CENTER|

DT_NOPREFIX|DT_SINGLELINE);

m_bDrawText=FALSE;

}

else

{

if(bCheck){

CSizesize=memDC.GetTextExtent((LPCTSTR)m_szWork,m_szWork.GetLength()-rmcode);

if(m_size.cxn_MaxWidth){

n_MaxWidth=(m_size.cxm_ScrollRect.Width())?m_ScrollRect.Width():m_size.cx;

m_ClientRect.left=(m_ScrollRect.Width()-n_MaxWidth)/2;

m_ClientRect.right=m_ClientRect.left+n_MaxWidth;

}

}

CRectr(m_pt.x,m_pt.y-m_nClip,m_pt.x+m_size.cx,m_pt.y);

//假设是位图,根据背景memDC和位图设备memDC2,在立异区域显示部分位图

DrawBitmap(memDC,memDC2,r);

//memDC.BitBlt(m_pt.x,m_pt.y-m_nClip,m_size.cx,m_nClip,

//memDC2,0,0,SRCCOPY);

if(m_nClip=m_size.cy)

{

m_bmpWork.DeleteObject();

m_bProcessingBitmap=FALSE;

m_nClip=0;

m_szWork.Empty();

m_nCounter=1;

}

}

//苏醒设备

if(pOldMemDC2Bitmap!=NULL)memDC2.SelectObject(pOldMemDC2Bitmap);

if(pOldFont!=NULL)memDC.SelectObject(pOldFont);

memDC.SelectObject(pOldMemDCBitmap);

}

voidCCreditStatic::DrawCredit(CDC*pDC,CRectm_ScrollRect)

{

if(m_BmpMain.m_hObject!=NULL)return;

CDCmemDC,memDC2;

memDC.CreateCompatibleDC(pDC);

memDC2.CreateCompatibleDC(pDC);

COLORREFBackColor=(m_bTransparentm_bitmap.m_hObject!=NULL)?RGB(192,192,192):m_Colors[BACKGROUND_COLOR];

CBitmap*pOldMemDCBitmap=NULL;

m_BmpMain.CreateCompatibleBitmap(pDC,m_ScrollRect.Width(),m_ScrollRect.Height());

pOldMemDCBitmap=(CBitmap*)memDC.SelectObject(m_BmpMain);

if(m_Gradientm_bitmap.m_hObject==NULL)

FillGradient(memDC,m_ScrollRect,m_ScrollRect,m_Colors[BACKGROUND_COLOR]);

else

memDC.FillSolidRect(m_ScrollRect,BackColor);

POSITIONpos=m_ArrCredit.GetHeadPosition();

intheight=0;

while(pos!=NULLheight=m_ScrollRect.Height()){

CStringm_szWork=m_ArrCredit.GetNext(pos);

CFontm_fntArial;

CFont*pOldFont=NULL;

CBitmap*pOldMemDC2Bitmap=NULL;

CDCmemDC2;

memDC2.CreateCompatibleDC(pDC);

//*********************************************************************

//FONTSELECTION

BOOLbSuccess=FALSE;

BOOLbIsBitmap=FALSE;

BOOLbUnderline;

BOOLbItalic;

intrmcode=0;

CBitmapbitmap;

if(!m_szWork.IsEmpty()){

charc=m_szWork[m_szWork.GetLength()-1];

if(c==m_Escapes[TOP_LEVEL_GROUP]){

rmcode=1;

bItalic=FALSE;

bUnderline=FALSE;

m_nCurrentFontHeight=m_TextHeights[TOP_LEVEL_GROUP_HEIGHT];

bSuccess=m_fntArial.CreateFont(m_TextHeights[TOP_LEVEL_GROUP_HEIGHT],0,0,0,

FW_BOLD,bItalic,bUnderline,0,

ANSI_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

PROOF_QUALITY,

VARIABLE_PITCH|0x04|FF_DONTCARE,

(LPSTR)Arial);

memDC.SetTextColor(m_Colors[TOP_LEVEL_GROUP_COLOR]);

pOldFont=memDC.SelectObject(m_fntArial);

}

elseif(c==m_Escapes[GROUP_TITLE]){

rmcode=1;

bItalic=FALSE;

bUnderline=FALSE;

m_nCurrentFontHeight=m_TextHeights[GROUP_TITLE_HEIGHT];

bSuccess=m_fntArial.CreateFont(m_TextHeights[GROUP_TITLE_HEIGHT],0,0,0,

FW_BOLD,bItalic,bUnderline,0,

ANSI_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

PROOF_QUALITY,

VARIABLE_PITCH|0x04|FF_DONTCARE,

(LPSTR)Arial);

memDC.SetTextColor(m_Colors[GROUP_TITLE_COLOR]);

pOldFont=memDC.SelectObject(m_fntArial);

}

elseif(c==m_Escapes[TOP_LEVEL_TITLE]){

rmcode=1;

bItalic=FALSE;

//bUnderline=TRUE;

bUnderline=FALSE;

m_nCurrentFontHeight=m_TextHeights[TOP_LEVEL_TITLE_HEIGHT];

bSuccess=m_fntArial.CreateFont(m_TextHeights[TOP_LEVEL_TITLE_HEIGHT],0,0,0,

FW_BOLD,bItalic,bUnderline,0,

ANSI_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

PROOF_QUALITY,

VARIABLE_PITCH|0x04|FF_DONTCARE,

(LPSTR)Arial);

memDC.SetTextColor(m_Colors[TOP_LEVEL_TITLE_COLOR]);

pOldFont=memDC.SelectObject(m_fntArial);

}

elseif(c==m_Escapes[DISPLAY_BITMAP]){

CStringszBitmap=m_szWork.Left(m_szWork.GetLength()-1);

if(bitmap.LoadBitmap((constchar*)szBitmap)){

BITMAPm_bmpInfo;

bitmap.GetObject(sizeof(BITMAP),m_bmpInfo);

m_size.cx=m_bmpInfo.bmWidth;//widthofdestrect

m_size.cy=m_bmpInfo.bmHeight;

//upperleftpointofdest

m_pt.x=(m_ScrollRect.right-

((m_ScrollRect.Width())/2)-(m_size.cx/2));

m_pt.y=height;

pOldMemDC2Bitmap=memDC2.SelectObject(bitmap);

bIsBitmap=TRUE;

}

else

c=;

}

else{

bItalic=FALSE;

bUnderline=FALSE;

m_nCurrentFontHeight=m_TextHeights[NORMAL_TEXT_HEIGHT];

bSuccess=m_fntArial.CreateFont(m_TextHeights[NORMAL_TEXT_HEIGHT],0,0,0,

FW_THIN,bItalic,bUnderline,0,

ANSI_CHARSET,

OUT_DEFAULT_PRECIS,

CLIP_DEFAULT_PRECIS,

PROOF_QUALITY,

VARIABLE_PITCH|0x04|FF_DONTCARE,

(LPSTR)Arial);

memDC.SetTextColor(m_Colors[NORMAL_TEXT_COLOR]);

pOldFont=memDC.SelectObject(m_fntArial);

}

}

memDC.SetBkMode(TRANSPARENT);

if(!bIsBitmap)

{

CRectr(m_ScrollRect);

r.top=height;

CSizesize;

if(m_szWork.GetLength()-rmcode!=0)

{

intx=memDC.DrawText((constchar*)m_szWork,m_szWork.GetLength()-rmcode,r,DT_TOP|DT_CENTER|

DT_NOPREFIX|DT_SINGLELINE);

size=memDC.GetTextExtent((LPCTSTR)m_szWork,m_szWork.GetLength()-rmcode);

}

else

size=memDC.GetTextExtent((LPCTSTR)W,1);

height+=size.cy;

}

else

{

CRectr(m_pt.x,m_pt.y,m_pt.x+m_size.cx,m_pt.y+m_size.cy);

DrawBitmap(memDC,memDC2,r);

//memDC.BitBlt(m_pt.x,m_pt.y,m_size.cx,m_size.cy,memDC2,0,0,SRCCOPY);

height+=m_size.cy;

}

if(pOldMemDC2Bitmap!=NULL)memDC2.SelectObject(pOldMemDC2Bitmap);

if(pOldFont!=NULL)memDC.SelectObject(pOldFont);

}

memDC.SelectObject(pOldMemDCBitmap);

}

voidCCreditStatic::OnDestroy()

{

CStatic::OnDestroy();

m_ArrCredit.RemoveAll();

if(TimerOn)

ASSERT(KillTimer(DISPLAY_TIMER_ID));

}

BOOLCCreditStatic::SetBkImage(UINTnIDResource)

{

returnSetBkImage((LPCTSTR)nIDResource);

}

//设置背景图片

BOOLCCreditStatic::SetBkImage(LPCTSTRlpszResourceName)

{

//删除从前的GDI对象

if(m_bitmap.m_hObject!=NULL)

m_bitmap.DeleteObject();

if(m_pal.m_hObject!=NULL)

m_pal.DeleteObject();

//载入位图

HBITMAPhBmp=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),

lpszResourceName,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);

if(hBmp==NULL)

returnFALSE;

m_bitmap.Attach(hBmp);

BITMAPbm;

m_bitmap.GetBitmap(bm);

m_cxBitmap=bm.bmWidth;

m_cyBitmap=bm.bmHeight;

//为位图创造逻辑调色板

DIBSECTIONds;

BITMAPINFOHEADERbmInfo=ds.dsBmih;

m_bitmap.GetObject(sizeof(ds),ds);

intnColors=bmInfo.biClrUsed?bmInfo.biClrUsed:1bmInfo.biBitCount;

//如若颜色大于256色,创造Halftone调色板

CClientDCdc(NULL);//DesktopDC

if(nColors256)

m_pal.CreateHalftonePalette(dc);

else

{

//不然,成立调色板

RGBQUAD*pRGB=newRGBQUAD[nColors];

CDCmemDC;

memDC.CreateCompatibleDC(dc);

CBitmap*pOldMemDCBitmap=memDC.SelectObject(m_bitmap);

::GetDIBColorTable(memDC,0,nColors,pRGB);

UINTnSize=sizeof(LOGPALETTE)+(sizeof(PALETTEENTRY)*nColors);

LOGPALETTE*pLP=(LOGPALETTE*)newBYTE[nSize];

pLP-palVersion=0x300;

pLP-palNumEntries=nColors;

for(inti=0;inColors;i++)

{

pLP-palPalEntry[i].peRed=pRGB[i].rgbRed;

pLP-palPalEntry[i].peGreen=pRGB[i].rgbGreen;

pLP-palPalEntry[i].peBlue=pRGB[i].rgbBlue;

pLP-palPalEntry[i].peFlags=0;

}

m_pal.CreatePalette(pLP);

memDC.SelectObject(pOldMemDCBitmap);

delete[]pLP;

delete[]pRGB;

}

returnTRUE;

}

2.CreditStatic.h的头文件代码

#if!defined(AFX_CREDITSTATIC_H__4ABD7701_49F5_11D1_9E3C_00A0245800CF__INCLUDED_)

#defineAFX_CREDITSTATIC_H__4ABD7701_49F5_11D1_9E3C_00A0245800CF__INCLUDED_

#if_MSC_VER=1000

#pragmaonce

#endif//_MSC_VER=1000

//CreditStatic.h:headerfile

//

#defineDISPLAY_SLOW0

#defineDISPLAY_MEDIUM1

#defineDISPLAY_FAST2

#defineBACKGROUND_COLOR0

#defineTOP_LEVEL_TITLE_COLOR1

#defineTOP_LEVEL_GROUP_COLOR2

#defineGROUP_TITLE_COLOR3

#defineNORMAL_TEXT_COLOR4

#defineTOP_LEVEL_TITLE_HEIGHT0

#defineTOP_LEVEL_GROUP_HEIGHT1

#defineGROUP_TITLE_HEIGHT2

#defineNORMAL_TEXT_HEIGHT3

#defineTOP_LEVEL_TITLE0//t

#defineTOP_LEVEL_GROUP1//n

#defineGROUP_TITLE2//r

#defineDISPLAY_BITMAP3//^

#defineGRADIENT_NONE0

#defineGRADIENT_RIGHT_DARK1

#defineGRADIENT_RIGHT_LIGHT2

#defineGRADIENT_LEFT_DARK3

#defineGRADIENT_LEFT_LIGHT4

classCCreditStatic:publicCStatic

{

protected:

COLORREFm_Colors[5];

intm_TextHeights[4];

TCHARm_Escapes[4];

intm_DisplaySpeed[3],m_CurrentSpeed;

//CRectm_ScrollRect;//rectofStaticTextframe

CStringListm_ArrCredit;

CStringm_szWork;

intm_nCounter;//workints

POSITIONm_ArrIndex;

BOOLm_bFirstTime;

BOOLm_bDrawText;

intm_nClip,m_ScrollAmount;

intm_nCurrentFontHeight;

CBitmapm_bmpWork;//bitmapholder

CBitmapm_BmpMain;//bitmapholder

CSizem_size;//drawinghelpers

CPointm_pt;

BOOLm_bProcessingBitmap;

CPalettem_pal;

CBitmapm_bitmap;

intm_cxBitmap,m_cyBitmap;

BOOLm_bFirstTurn;

UINTm_Gradient;

BOOLm_bTransparent;

intn_MaxWidth;

UINTTimerOn;

//Construction

public:

CCreditStatic();

//Attributes

public:

//Operations

public:

BOOLStartScrolling();

voidEndScrolling();

voidSetCredits(LPCTSTRcredits,chardelimiter=|);

voidSetCredits(UINTnID,chardelimiter=|);

voidSetSpeed(UINTindex,intspeed=0);

voidSetColor(UINTindex,COLORREFcol);

voidSetTextHeight(UINTindex,intheight);

voidSetEscape(UINTindex,charescape);

voidSetGradient(UINTvalue=GRADIENT_RIGHT_DARK);

BOOLSetBkImage(UINTnIDResource);

BOOLSetBkImage(LPCTSTRlpszResourceName);

voidSetTransparent(BOOLbTransparent=TRUE);

//Overrides

//ClassWizardgeneratedvirtualfunctionoverrides

//{{AFX_VIRTUAL(CCreditStatic)

//}}AFX_VIRTUAL

//Implementation

public:

virtual~CCreditStatic();

//Generatedmessagemapfunctions

protected:

voidMoveCredit(CDC*pDC,CRectr,CRectr2,BOOLbCheck);

voidAddBackGround(CDC*pDC,CRectm_ScrollRect,CRectm_ClientRect);

voidDrawCredit(CDC*pDC,CRectm_ScrollRect);

voidFillGradient(CDC*pDC,CRect*m_ScrollRect,CRect*m_FillRect,COLORREFcolor);

voidDrawBitmap(CDC*pDC,CDC*pDC2,CRect*rBitmap);

//{{AFX_MSG(CCreditStatic)

afx_msgvoidOnPaint();

afx_msgBOOLOnEraseBkgnd(CDC*pDC);

afx_msgvoidOnTimer(UINTnIDEvent);

afx_msgvoidOnDestroy();

//}}AFX_MSG

DECLARE_MESSAGE_MAP()

};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}

//MicrosoftDeveloperStudiowillinsertadditionaldeclarationsimmediatelybeforethepreviousline.

#endif//!defined(AFX_CREDITSTATIC_H__4ABD7701_49F5_11D1_9E3C_00A0245800CF__INCLUDED_)

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图