Example #1
0
//抽奖信息的绘制
void CLotteryDlg::_drawLotteryInfo(CDC* pDC)
{
	pDC->SetBkMode(TRANSPARENT);
	CFont* pOldFont = pDC->SelectObject(&m_TitleFont);
	pDC->SetTextColor(RGB(255, 255, 255));
	//绘制标题
	CString str = L"天极传媒.上海2013迎春年会抽奖仪式---lgy";
	str.SetString(m_uiInfo._title.c_str());
	CSize size = pDC->GetTextExtent(str);
	pDC->TextOut(m_ClientRect.CenterPoint().x - size.cx/2, m_ClientRect.top + m_ClientRect.Height() / 8, str, str.GetLength());
	pDC->SelectObject(pOldFont);

	if (m_bRollTimer)
	{
		pDC->SetTextColor(RGB(255,255,0));
		pOldFont = pDC->SelectObject(&m_NormalFont);
		str = L"正在抽取";
		int xPos = m_ClientRect.left + m_leftWidth;
		int yPos = m_ClientRect.bottom - m_ClientRect.Height()/10;

		pDC->TextOut(xPos, yPos - 5, str, str.GetLength());
		xPos += pDC->GetTextExtent(str+L"123").cx;
		pDC->SelectObject(pOldFont);

		pOldFont = pDC->SelectObject(&m_KeyFont);
		str.SetString(m_uiInfo._curClass.c_str());//奖项
		pDC->TextOut(xPos, yPos, str, str.GetLength());

		str.SetString(m_uiInfo._curAward.c_str());//奖品
		str = L"奖品 : " + str;
		pDC->TextOut(m_ClientRect.CenterPoint().x, yPos, str, str.GetLength());
		pDC->SelectObject(pOldFont);
	}

}
Example #2
0
void CLotteryDlg::_readTheRandPartnerPic()
{
	CString strFilePath;
	CPaintDC hDC(this);
	m_PicWidth = 0;
	m_PicHeight = 0;
	int index = 0;
	//一次读取生成的随机数对应的编号中的字符串
	for (std::set<size_t>::iterator iter = m_RandNo.begin(); iter != m_RandNo.end(); ++iter)
	{
		strFilePath.SetString(m_PartnerPicPath[*iter].c_str());//设置读取的文件路径中的字符串
		if (!_loadPic(strFilePath, &m_PartnerPicInfo[index]))
		{
			AfxMessageBox(_T("加载图片:") + strFilePath + _T("出错"));
			continue;
		}
		m_PartnerPicInfo[index]._width = MulDiv(m_PartnerPicInfo[index]._cx, GetDeviceCaps(hDC, LOGPIXELSX), 2540);
		m_PartnerPicInfo[index]._height = MulDiv(m_PartnerPicInfo[index]._cy, GetDeviceCaps(hDC, LOGPIXELSY), 2540);
		m_PicWidth += m_PartnerPicInfo[index]._width;
		if (m_PicHeight < m_PartnerPicInfo[index]._height)
			m_PicHeight = m_PartnerPicInfo[index]._height;
		index++;
	}
	m_PicWidth /= sizeof(m_PartnerPicInfo)/sizeof(m_PartnerPicInfo[0]);
	_calcMargin();
}
Example #3
0
/*
================
SpinFloatString
================
*/
void SpinFloatString( CString &str, bool up ) {
	int i, dotIndex = -1, digitIndex = -1;

	for ( i = 0; str[i]; i++ ) {
		if ( str[i] == '.' ) {
			if ( dotIndex == -1 ) {
				dotIndex = i;
			}
		}
		else if ( str[i] != '0' ) {
			if ( digitIndex == -1 ) {
				digitIndex = i;
			}
		}
	}
	if ( digitIndex == -1 ) {
		str.SetString( "1" );
		return;
	}

	if ( dotIndex != -1 ) {
		str.Delete( dotIndex, 1 );
		if ( digitIndex > dotIndex ) {
			digitIndex--;
		}
	}
	else {
		dotIndex = i;
	}

	if ( up ) {
		if ( str[digitIndex] == '9' ) {
			str.SetAt( digitIndex, '0' );
			if ( digitIndex == 0 ) {
				str.Insert( 0, '1' );
				dotIndex++;
			}
			else {
				str.SetAt( digitIndex-1, '1' );
			}
		}
		else {
			str.SetAt( digitIndex, str[digitIndex] + 1 );
		}
	}
	else {
		if ( str[digitIndex] == '1' ) {
			if ( str[digitIndex+1] == '\0' ) {
				str.SetAt( digitIndex, '0' );
				str.AppendChar( '9' );
			}
			else if ( str[digitIndex+1] == '0' ) {
				str.SetAt( digitIndex, '0' );
				str.SetAt( digitIndex+1, '9' );
			}
			else {
				str.SetAt( digitIndex+1, str[digitIndex+1] - 1 );
			}
		}
		else {
			str.SetAt( digitIndex, str[digitIndex] - 1 );
		}
	}
	if ( dotIndex < str.GetLength() ) {
		str.Insert( dotIndex, '.' );
		// remove trailing zeros
		for ( i = str.GetLength()-1; i >= 0; i-- ) {
			if ( str[i] != '0' && str[i] != '.' ) {
				break;
			}
		}
		if ( i < str.GetLength() - 1 ) {
			str.Delete( i+1, str.GetLength() - i );
		}
	}
	for ( i = 0; str[i]; i++ ) {
		if ( str[i] == '.' ) {
			if ( i > 1 ) {
				str.Delete( 0, i-1 );
			}
			break;
		}
		if ( str[i] != '0' ) {
			if ( i > 0 ) {
				str.Delete( 0, i );
			}
			break;
		}
	}
}