⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 creditstatic.cpp

📁 mod_RSsim
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	for( int i = 0; i < m_ScrollRect.right; i += m_cxBitmap )
		for( int j = 0; j < m_ScrollRect.bottom; j += m_cyBitmap )
			imageDC.BitBlt( i, j, m_cxBitmap, m_cyBitmap, &tempDC, 0, 0, SRCCOPY );

	// Set the background in memDC to black. Using SRCPAINT with black and any other
	// color results in the other color, thus making black the transparent color
	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);

	// Set the foreground to black. See comment above.
	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);

	// Combine the foreground with the background
    imageDC.BitBlt(m_ClientRect.left, m_ClientRect.top, m_ClientRect.Width(), m_ClientRect.Height(), 
					&memDC, 0, 0,SRCPAINT);

	// Draw the final image to the screen   
	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);
}

void CCreditStatic::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;
	}

	CDC memDC;
	memDC.CreateCompatibleDC( pDC );

    // Now create a mask
	CBitmap bitmap;
	bitmap.CreateCompatibleBitmap( pDC, rBitmap->Width(), rBitmap->Height() );
	CBitmap* pOldMemDCBitmap = memDC.SelectObject( &bitmap );
		
	memDC.BitBlt( 0, 0, rBitmap->Width(), rBitmap->Height(), pDC2, 0, 0, SRCCOPY );

	CDC maskDC;
	maskDC.CreateCompatibleDC(pDC);

	// Create monochrome bitmap for the mask
	CBitmap maskBitmap;
	maskBitmap.CreateBitmap( rBitmap->Width(), rBitmap->Height(), 1, 1, NULL );
	CBitmap* pOldMaskDCBitmap = maskDC.SelectObject( &maskBitmap );
    memDC.SetBkColor(RGB(192,192,192));

	// Create the mask from the memory DC
	maskDC.BitBlt( 0, 0, rBitmap->Width(), rBitmap->Height(), &memDC, 0, 0, SRCCOPY );


	CDC imageDC;
	CBitmap bmpImage;
	imageDC.CreateCompatibleDC( pDC );
	bmpImage.CreateCompatibleBitmap( pDC, rBitmap->Width(), rBitmap->Height() );
	CBitmap* pOldImageDCBitmap = imageDC.SelectObject( &bmpImage );

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

	// Set the background in memDC to black. Using SRCPAINT with black and any other
	// color results in the other color, thus making black the transparent color
	memDC.SetBkColor(RGB(0,0,0));
	memDC.SetTextColor(RGB(255,255,255));
	memDC.BitBlt(0, 0, rBitmap->Width(), rBitmap->Height(), &maskDC, 0, 0, SRCAND);

	// Set the foreground to black. See comment above.
	imageDC.SetBkColor(RGB(255,255,255));
	imageDC.SetTextColor(RGB(0,0,0));
	imageDC.BitBlt(0, 0, rBitmap->Width(), rBitmap->Height(), &maskDC, 0, 0, SRCAND);

	// Combine the foreground with the background
    imageDC.BitBlt(0, 0, rBitmap->Width(), rBitmap->Height(), &memDC, 0, 0,SRCPAINT);

	// Draw the final image to the screen   
	pDC->BitBlt( rBitmap->left, rBitmap->top, rBitmap->Width(), rBitmap->Height(), 
					&imageDC, 0, 0, SRCCOPY );

	imageDC.SelectObject(pOldImageDCBitmap);
	maskDC.SelectObject(pOldMaskDCBitmap);
	memDC.SelectObject(pOldMemDCBitmap);
}

void CCreditStatic::FillGradient(CDC *pDC, CRect *m_ScrollRect, CRect *m_FillRect, COLORREF color)
{ 
	float fStep,fRStep,fGStep,fBStep;	    // How large is each band?
	int iOnBand;  // Loop index

	WORD R = GetRValue(color);
	WORD G = GetGValue(color);
	WORD B = GetBValue(color);

	// Determine how large each band should be in order to cover the
	// client with 256 bands (one for every color intensity level)
	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;
	}

	COLORREF OldCol = pDC->GetBkColor();
	// Start filling bands
	fStep = (float)m_ScrollRect->Width() / 256.0f;
	for(iOnBand = (256*m_FillRect->left)/m_ScrollRect->Width(); 
		(int)(iOnBand*fStep) < m_FillRect->right && iOnBand < 256; iOnBand++) {
		CRect r((int)(iOnBand * fStep), m_FillRect->top,
				(int)((iOnBand+1) * fStep), m_FillRect->bottom+1);
		COLORREF col;

		switch(m_Gradient) {
		case GRADIENT_RIGHT_DARK:
			col = RGB((int)(R-iOnBand*fRStep),(int)(G-iOnBand*fGStep),(int)(B-iOnBand*fBStep));
			break;
		case GRADIENT_RIGHT_LIGHT:
			col = RGB((int)(R+iOnBand*fRStep),(int)(G+iOnBand*fGStep),(int)(B+iOnBand*fBStep));
			break;
		case GRADIENT_LEFT_DARK:
			col = RGB((int)(iOnBand*fRStep),(int)(iOnBand*fGStep),(int)(iOnBand*fBStep));
			break;
		case GRADIENT_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);
} 

#define SCROLLDC

// --------------------------------------- MoveCredit -----------------------------
void CCreditStatic::MoveCredit(CDC* pDC, CRect& m_ScrollRect, CRect& m_ClientRect, BOOL bCheck)
{
	CDC memDC,memDC2;
   memDC.CreateCompatibleDC(pDC);
   memDC2.CreateCompatibleDC(pDC);
    
	COLORREF BackColor = (m_bTransparent && m_bitmap.m_hObject != NULL)? RGB(192,192,192) : m_Colors[BACKGROUND_COLOR];
	CBitmap *pOldMemDCBitmap = NULL;
	CBitmap	*pOldMemDC2Bitmap = NULL;

#ifdef SCROLLDC
	CRect r1;
#endif

	if(m_BmpMain.m_hObject == NULL) {
		m_BmpMain.CreateCompatibleBitmap( pDC, m_ScrollRect.Width(), m_ScrollRect.Height() );
		pOldMemDCBitmap = (CBitmap*)memDC.SelectObject(&m_BmpMain);
		if(m_Gradient && m_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) {
#ifndef SCROLLDC
		CBitmap bitmap;
		bitmap.CreateCompatibleBitmap( pDC, m_ClientRect.Width(), m_ClientRect.Height() );
		pOldMemDC2Bitmap = memDC2.SelectObject(&bitmap);

		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
		CRgn RgnUpdate;
		memDC.ScrollDC(0,m_ScrollAmount,(LPCRECT)m_ScrollRect,(LPCRECT)m_ClientRect,&RgnUpdate,
						(LPRECT)r1);
    }
	else {
		r1 = m_ScrollRect;
		r1.top = r1.bottom-abs(m_ScrollAmount);
#endif
	}

	m_nClip = m_nClip + abs(m_ScrollAmount);	
	

	//*********************************************************************
	//	FONT SELECTION
   CFont m_fntArial;
	CFont* pOldFont = NULL;
	BOOL bSuccess = FALSE;
	
	BOOL bUnderline;
	BOOL bItalic;
   int rmcode = 0;

	if (!m_szWork.IsEmpty()) 
   {
		char c = 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];
   			bSuccess = m_fntArial.CreateFont(m_TextHeights[TOP_LEVEL_GROUP], 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);
			
		}
		else if(c == m_Escapes[GROUP_TITLE]) 
      {
			rmcode = 1;
			bItalic = FALSE;
			bUnderline = FALSE;
			m_nCurrentFontHeight = m_TextHeights[GROUP_TITLE];
   			bSuccess = m_fntArial.CreateFont(m_TextHeights[GROUP_TITLE], 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);
		}
		else if(c == m_Escapes[TOP_LEVEL_TITLE]) 
      {
			rmcode = 1;
			bItalic = FALSE;
//			bUnderline = TRUE;
			bUnderline = FALSE;
			m_nCurrentFontHeight = m_TextHeights[TOP_LEVEL_TITLE];
			bSuccess = m_fntArial.CreateFont(m_TextHeights[TOP_LEVEL_TITLE], 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);
		}
		else if(c == m_Escapes[DISPLAY_BITMAP]) 
      {
			if (!m_bProcessingBitmap)
			{
				CString szBitmap = m_szWork.Left(m_szWork.GetLength()-1);
				if(m_bmpWork.LoadBitmap((const char *)szBitmap)) {
					BITMAP 		m_bmpInfo;

	   				m_bmpWork.GetObject(sizeof(BITMAP), &m_bmpInfo);
			
					m_size.cx = m_bmpInfo.bmWidth;	// width  of dest rect
					m_size.cy = m_bmpInfo.bmHeight;
					// upper left point of dest
					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);
				}
				else
					c = ' ';
			}
			else {
				if (pOldMemDC2Bitmap != NULL) memDC2.SelectObject(pOldMemDC2Bitmap);
				pOldMemDC2Bitmap = memDC2.SelectObject(&m_bmpWork);
			}
		}
		else 
         if ((c == m_Escapes[LEFT_ALIGN1]) || 
             (c == m_Escapes[LEFT_ALIGN2]) ||
             (c == m_Escapes[NORMAL_CENTER]))
         { // left align 1, 2 and normal font
			rmcode = 1;
			bItalic = FALSE;
			bUnderline = FALSE;
			m_nCurrentFontHeight = m_TextHeights[NORMAL_CENTER];
   		bSuccess = m_fntArial.CreateFont(m_TextHeights[NORMAL_CENTER], 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);
      }
      else  // 
      { // default 
			bItalic = FALSE;
			bUnderline = FALSE;
			m_nCurrentFontHeight = m_TextHeights[NORMAL_CENTER];
   			bSuccess = m_fntArial.CreateFont(m_TextHeights[NORMAL_CENTER], 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);
		}
	}

#ifndef SCROLLDC
	CRect r1(m_ScrollRect);
	r1.top = r1.bottom-abs(m_ScrollAmount);
#endif

	if(m_Gradient && m_bitmap.m_hObject == NULL)
		FillGradient(&memDC, &m_ScrollRect, &r1, m_Colors[BACKGROUND_COLOR]);
	else
		memDC.FillSolidRect(&r1,BackColor);
	memDC.SetBkMode(TRANSPARENT);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -