Exemplo n.º 1
0
// Set the axes and origin values.
void MyGraph::SetupAxes(CDC& dc)
{
	VALIDATE;
	ASSERT_VALID(&dc);

	// Since pie has no axis lines, set to full size minus GAP_PIXELS on each
	// side.  These are needed for legend to plot itself.
	if (MyGraph::PieChart == m_eGraphType) {
		m_nXAxisWidth = m_rcGraph.Width() - (GAP_PIXELS * 2);
		m_nYAxisHeight = m_rcGraph.Height() - m_rcTitle.bottom;
		m_ptOrigin.x = GAP_PIXELS;
		m_ptOrigin.y = m_rcGraph.Height() - GAP_PIXELS;
	}
	else {
		// Bar and Line graphs.

		// Need to find out how wide the biggest Y-axis tick label is

		// Get and store height of axis label font.
		m_nAxisLabelHeight = max(m_rcGraph.Height() / Y_AXIS_LABEL_DIVISOR, MIN_FONT_SIZE);
		// Get and store height of tick label font.
		m_nAxisTickLabelHeight = max(int(m_nAxisLabelHeight*0.8), MIN_FONT_SIZE);

		CFont fontTickLabels;
		VERIFY(fontTickLabels.CreatePointFont(m_nAxisTickLabelHeight, _T("Arial"), &dc));
		// Select font and store the old.
		CFont* pFontOld = dc.SelectObject(&fontTickLabels);
		ASSERT_VALID(pFontOld);

		// Obtain tick label dimensions.
		CString sTickLabel;
		sTickLabel.Format(_T("%d"), GetMaxDataValue());
		CSize sizTickLabel(dc.GetTextExtent(sTickLabel));

		// Set old font object again and delete temporary font object.
		VERIFY(dc.SelectObject(pFontOld));
		fontTickLabels.DeleteObject();

		// Determine axis specifications.
		m_ptOrigin.x = m_rcGraph.left + m_nAxisLabelHeight/10 + 2*GAP_PIXELS
			+ sizTickLabel.cx + GAP_PIXELS + TICK_PIXELS;
		m_ptOrigin.y = m_rcGraph.bottom - m_nAxisLabelHeight/10 - 2*GAP_PIXELS -
			sizTickLabel.cy - GAP_PIXELS - TICK_PIXELS;
		m_nYAxisHeight = m_ptOrigin.y - m_rcTitle.bottom - (2 * GAP_PIXELS);
		m_nXAxisWidth = (m_rcGraph.Width() - GAP_PIXELS) - m_ptOrigin.x;
	}
}
Exemplo n.º 2
0
void CStackWnd::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	CFont* pOldFont = dc.SelectObject(&m_Font);
	pOldFont->DeleteObject();
	
	RECT rc;
	GetClientRect(&rc);

	DWORD dwSelStart = std::min(m_dwSelStart,m_dwSelEnd);
	DWORD dwSelEnd = std::max(m_dwSelStart,m_dwSelEnd);

	for (int i=0;i*m_nLineHight<=rc.bottom;++i)
	{
		RECT tmp = rc;
		tmp.top = i*m_nLineHight;
		tmp.bottom = tmp.top + m_nLineHight;
			

		DWORD data;
		DWORD dwLineAddr = m_dwStartAddr+i*4;
		SIZE_T nRead = 0;

		if (dwLineAddr>=dwSelStart && dwLineAddr <=dwSelEnd)
		{
			dc.SetBkColor(0x00FF0000);
		}

		if (debug_kernel_ptr && debug_kernel_ptr->read_memory(dwLineAddr,&data,4,&nRead) && nRead == 4)
		{
			char line[20];
			sprintf(line,"%08X %08X",dwLineAddr,data);
			dc.ExtTextOut(0,i*m_nLineHight,ETO_OPAQUE,&tmp,line,17,NULL);
		}
		else
		{
			char line[20];
			sprintf(line,"%08X ???",dwLineAddr);
			dc.ExtTextOut(0,i*m_nLineHight,ETO_OPAQUE,&tmp,line,12,NULL);
		}

		dc.SetBkColor(0x00FFFFFF);
	}
	// 不为绘图消息调用 CWnd::OnPaint()
}
Exemplo n.º 3
0
CFont* CGridCell::GetFontObject() const
{
	// If the default font is specified, use the default cell implementation
	if (m_plfFont == nullptr)
	{
		const CGridDefaultCell* pDefaultCell = static_cast<const CGridDefaultCell*>(GetConstDefaultCell());
		if (!pDefaultCell)
			return nullptr;

		return pDefaultCell->GetFontObject();
	}
	else
	{
		static CFont Font;
		Font.DeleteObject();
		Font.CreateFontIndirect(m_plfFont);
		return &Font;
	}
}
Exemplo n.º 4
0
CFont* Printing::CPntGridCell::GetFontObject( CDC* pDC /*= NULL*/ ) const
{
    // If the default font is specified, use the default cell implementation
    if (m_plfFont == NULL)
    {
        CPntGridDefaultCell *pDefaultCell = (CPntGridDefaultCell*) GetDefaultCell();
        if (!pDefaultCell)
            return NULL;

        return pDefaultCell->GetFontObject();
    }
    else
    {
        static CFont Font;
        Font.DeleteObject();
        Font.CreatePointFont(m_plfFont->lfHeight, m_plfFont->lfFaceName, pDC);
        return &Font;
    }
}
Exemplo n.º 5
0
CFont* CGridCell::GetFontObject() const
{
    // If the default font is specified, use the default cell implementation
    if (m_plfFont == NULL)
    {
        CGridDefaultCell *pDefaultCell = (CGridDefaultCell*) GetDefaultCell();
        if (!pDefaultCell)
            return NULL;

        return pDefaultCell->GetFontObject();
    }
    else
    {
        static CFont Font;
        Font.DeleteObject();
        Font.CreateFontIndirect(m_plfFont);
        return &Font;
    }
}
Exemplo n.º 6
0
void MenuItemSprite::Draw(HDC hDC)
{
	if(m_pBitmap&&!m_bHidden)
	{
		m_pBitmap->DrawPart(hDC,m_rcPosition.left,m_rcPosition.top,0,m_iCurFrame*GetHeight(),GetWidth(),GetHeight(),FALSE);
		if(m_iCurFrame==7&&m_bWithText)
		{
			int oldMode;
			COLORREF oldColor;
			CFont cf;
			cf.CreateFont(
				19,                        // nHeight
				0,                         // nWidth
				0,                         // nEscapement
				0,                         // nOrientation
				FW_NORMAL,                 // nWeight
				FALSE,                     // bItalic
				FALSE,                     // bUnderline
				0,                         // cStrikeOut
				ANSI_CHARSET,              // nCharSet
				OUT_DEFAULT_PRECIS,        // nOutPrecision
				CLIP_DEFAULT_PRECIS,       // nClipPrecision
				DEFAULT_QUALITY,           // nQuality
				DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
				"���ו"); 

			HFONT oldFont=(HFONT)SelectObject(hDC,cf.m_hObject);

			oldColor=SetTextColor(hDC,RGB(252,252,56));
			oldMode=SetBkMode(hDC,TRANSPARENT);
			RECT rt=m_rcPosition;
			rt.left-=4;rt.right-=4;
			rt.top++;rt.bottom++;
			DrawText(hDC,m_strText,-1,&rt,DT_CENTER|DT_SINGLELINE|DT_VCENTER);
			
			SelectObject(hDC,oldFont);
			cf.DeleteObject();
			SetTextColor(hDC,oldColor);
			SetBkMode(hDC,oldMode);
		}
	}
}
Exemplo n.º 7
0
BOOL CNineShowView::InitGridContent(CNineGridCtrl *pGrid )  
{
	m_nCols=4;
    m_nFixRows=1;
	m_nFixCols=0;
    m_nRows=20;  


	try {
 		pGrid->SetRowCount(m_nRows);
		pGrid->SetColumnCount(m_nCols);
		pGrid->SetFixedRowCount(m_nFixRows);
		pGrid->SetFixedColumnCount(m_nFixCols);
	}
	catch (CMemoryException* e)
	{
		e->ReportError();
		e->Delete();
		return FALSE;
	}
   	pGrid->SetGridColor(m_pDoc->m_colorArray[18],m_pDoc->m_colorArray[17],m_pDoc->m_colorArray[16]);

//20000615
    pGrid->SetFixedBkColor(m_pDoc->m_colorArray[18]);
//20000615


	CFont Font;
	LOGFONT m_lf;
	memset(&m_lf,0,sizeof(LOGFONT));
	m_lf.lfHeight = -12;
	m_lf.lfWidth=0;
	m_lf.lfWeight=400;
	m_lf.lfCharSet=134;
	strcpy(m_lf.lfFaceName,"宋体");

	Font.CreateFontIndirect(&m_lf);

	pGrid->SetFont(&Font);
	Font.DeleteObject();
 	return TRUE;
}
Exemplo n.º 8
0
void CMainDialog::SetNewFont()
{
  CFont font;

  font.CreateFont(m_height, 0, 0, 0, m_weight, FALSE, FALSE, FALSE, DEFAULT_CHARSET /*ANSI_CHARSET*/,
    OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
    DEFAULT_PITCH | FF_SWISS /*FF_DONTCARE*/, m_facename.GetBuffer(0));

  m_example_text.SetFont(&font, TRUE);

  #ifdef _DEBUG
  {
    LOGFONT lf;
    font.GetLogFont(&lf);
    TRACE("  Typeface = %s\n", lf.lfFaceName);
    TRACE("  Charset = %d\n", lf.lfCharSet);
  }
  #endif

  font.DeleteObject();
}
Exemplo n.º 9
0
CFont * AfxSelectDCFont( CDC * pDC, int nHeight )
{
	static	CFont	font;
	font.DeleteObject();

#ifdef CLKLAN_ENGLISH_US
	if( nHeight <= 15 )
	{
		CFont *pFont = CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT));
		return	pDC->SelectObject( pFont );
	}
	else
	{
		return NULL;
	}
#else
	font.CreateFont(nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0,
					DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH,
					"楷体" );
	return	pDC->SelectObject( &font );
#endif
}
Exemplo n.º 10
0
void CAppealDlg::OnPaint()
{
    CPaintDC dc(this); // device context for painting
    // TODO: 在此处添加消息处理程序代码
    // 不为绘图消息调用 CDialog::OnPaint()

    /*// 2012.12.16 yyf 屏蔽
    CGameImageHelper helplt(&m_imgDlgBk);
    helplt.BitBlt(dc.GetSafeHdc(),0,0);*/

    //绘画框架底图 2012.10.16 yyf
    m_configDlg.DrawViewFrame(&dc);

    CFont font;
    font.CreateFont(-12,0,0,0,400,0,0,0,DEFAULT_CHARSET,3,2,1,2,TEXT("Arial"));
    CFont* pOldFont = (CFont*)dc.SelectObject(&font);
    dc.SetBkMode(TRANSPARENT);

    CBcfFile fMsg(CBcfFile::GetAppPath()+"ClientMessage.bcf");

    dc.SetTextColor(RGB(252,255,255));
    CString strTitle = fMsg.GetKeyVal("AppealDlg","UserFeedBack","用户反馈");
    dc.TextOut(5,5,strTitle);
    //dc.TextOut(strTitle,5,5);
    dc.SetTextColor(RGB(0,0,0));
    strTitle = fMsg.GetKeyVal("AppealDlg","UserName","用户名:");
    dc.TextOut(20,50,strTitle);
    strTitle = fMsg.GetKeyVal("AppealDlg","Telephone","联系电话:");
    dc.TextOut(20,90,strTitle);
    strTitle = fMsg.GetKeyVal("AppealDlg","Email","Email:");
    dc.TextOut(20,130,strTitle);

    /// {{Added by zxd 20100709 释放GDI资源
    dc.SelectObject(pOldFont);
    font.DeleteObject();
    /// Added by zxd 20100709 释放GDI资源}}

}
Exemplo n.º 11
0
//重画函数
void CPrompt::OnPaint() 
{
	CPaintDC dc(this); 

	//设置 DC
	dc.SetBkMode(TRANSPARENT);
	dc.SetTextColor(RGB(0,0,0));
	dc.SelectObject(CSkinResourceManager::GetDefaultFont());

	//创建字体
	CFont ViewFont;
	ViewFont.CreateFont(-12,0,0,0,400,0,0,0,134,3,2,1,1,TEXT("Arial"));
	CFont *pOldFont=dc.SelectObject(&ViewFont);

	CRect rcScore(0,30,220,30+19);
	dc.DrawText(m_tStr,lstrlen(m_tStr),&rcScore,DT_VCENTER|DT_CENTER|DT_END_ELLIPSIS);

	//还原字体
	dc.SelectObject(pOldFont);
	ViewFont.DeleteObject();

	return;
}
Exemplo n.º 12
0
void CMarkComboCtrl::Paint (CDC& dc) {
	CSize szShape;
	CRect rectCtrl, rectLabel;
	CMark mrkStyle;
	CFont fntDeflt;
	uvar32_64 szKernel;

	dc.FillSolidRect (m_rectText, ::GetSysColor (COLOR_WINDOW));
	mrkStyle = theApp.MarkStyles[aimActive].GetStyle();
	szShape = mrkStyle.GetShapeSize ();
	szKernel = mrkStyle.GetKernelSize ();

	m_rectText.DeflateRect (4, 4);
	rectLabel = m_rectText;
	m_rectText.right -= 100;
	rectLabel.left = m_rectText.right + 1;
	m_rectText.left -= (m_rectText.Height() - m_rectText.Width ()) / 2;
	m_rectText.right += (m_rectText.Height() - m_rectText.Width ()) / 2;
	if (szShape.cx >= szShape.cy) {
		m_rectText.top += (szShape.cx - szShape.cy) / 2;
		m_rectText.bottom -= (szShape.cx - szShape.cy) / 2;
	} else {
		m_rectText.left += (szShape.cy - szShape.cx) / 2;
		m_rectText.right -= (szShape.cy - szShape.cx) / 2;
	}
	GetClientRect (&rectCtrl);
	mrkStyle.SetPoint (CPoint ((rectCtrl.Width () - 115 )/ 2, rectCtrl.Height () / 2));
	mrkStyle.SetShapeSize (CSize (m_rectText.Width () - 2, m_rectText.Height () - 2));
	mrkStyle.SetKernelSize ((szKernel > m_rectText.Height())?m_rectText.Height():szKernel);
	mrkStyle.Paint (dc);

	fntDeflt.CreatePointFont (80, "Tahoma", &dc);
	CFont *pFont = dc.SelectObject (&fntDeflt);
	dc.DrawText (theApp.MarkStyles[aimActive].GetName (), rectLabel, DT_END_ELLIPSIS | DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
	dc.SelectObject (pFont);
	fntDeflt.DeleteObject ();
}
Exemplo n.º 13
0
void CSpecEdit::OnKillFocus(CWnd* pNewWnd)
{
	CEdit::OnKillFocus(pNewWnd);

	// TODO: Add your message handler code here
	if (this->m_ComboID==cmb3)
	{
		CString str;
		LOGFONT lf;
		CFont* pFont = ((CMyFontDlg*)m_pDlg)->GetSelectedFont();
		pFont->GetLogFont(&lf);
		pFont->DeleteObject();
		
		GetWindowText(str);
		if (str.GetLength()==0)
		{
			::SendMessage(m_pDlg->GetDlgItem(cmb3)->m_hWnd, CB_SETCURSEL, 0, 0);
			GetWindowText(str);
		}

		int k = _wtoi(str);
		lf.lfHeight = -MulDiv(k, GetDeviceCaps(GetParent()->GetDC()->m_hDC, LOGPIXELSY), 72);
		pFont->CreateFontIndirectW(&lf);
		m_pDlg->InvalidateRect(&((CMyFontDlg*)m_pDlg)->TextRect);		
	}

	if (this->m_ComboID==cmb2)
	{
		CString str;
		GetWindowText(str);
		CComboBox* pComboBox = (CComboBox*)(m_pDlg->GetDlgItem(cmb2));
		if (str.GetLength()==0 || pComboBox->GetCurSel()==-1)
		{
			::SendMessageW(m_pDlg->GetDlgItem(cmb2)->m_hWnd, CB_SETCURSEL, 0, 0);
		}
	}
}
Exemplo n.º 14
0
// *********************************************************************
// 					ReleaseFonts()										
// *********************************************************************
void GdiLabelDrawer::ReleaseFonts(bool useVariableFontSize)
{
	if (useVariableFontSize)
	{
		for (int i = 0; i <= MAX_LABEL_SIZE; i++)
		{
			if (_fonts[i])
			{
				CFont * f = _fonts[i];
				f->DeleteObject();
				delete f;
				_fonts[i] = NULL;
			}
		}
	}
	else {
		if (_font)
		{
			_font->DeleteObject();
			delete _font;
			_font = NULL;
		}
	}
}
Exemplo n.º 15
0
void CDianMu::OnPaint()
{
	CPaintDC dc(this); 
	//SetWindowPos(&wndBottom,0,0,242,137,SWP_NOZORDER);
	CGameImageHelper handle(&m_bk);
	handle.BitBlt(dc,0,0);
	dc.SetBkMode(TRANSPARENT);

	CFont font; //JMod-字体格式修改-20090631
	font.CreateFont(-12,0,0,0,400,NULL,NULL,NULL,134,3,2,1,2,TEXT("宋体"));
	CFont *pOldFont = dc.SelectObject(&font);	
	dc.TextOut(m_iDestX,m_iDestY,m_strMessage);
	dc.SelectObject(pOldFont);
	font.DeleteObject();

	//jph 100127
	HRGN hRgn;
	hRgn=AFCBmpToRgn(m_bk,RGB(255,0,255),RGB(1,1,1));
	if(hRgn)
	{
		SetWindowRgn(hRgn,true);
	}

}
Exemplo n.º 16
0
Arquivo: Dib.cpp Projeto: F5000/spree
BOOL CDIB::CreateFromText(CDC *pDC, LPCTSTR szString, COLORREF fontcolor, int width, LPCTSTR szSecondString, int secondoffset )
{
	Destroy ();

	CFont		pfont;	
	LOGFONT		lf;

	lf.lfHeight=16;
	lf.lfWidth=0;
	lf.lfEscapement=0;
	lf.lfOrientation=0;
	lf.lfWeight=FW_NORMAL;
	lf.lfItalic=0;
	lf.lfUnderline=0;
	lf.lfStrikeOut=0;
	lf.lfCharSet=DEFAULT_CHARSET; //ANSI_CHARSET;
	lf.lfOutPrecision=OUT_DEFAULT_PRECIS;
	lf.lfClipPrecision=CLIP_DEFAULT_PRECIS;
	lf.lfQuality=PROOF_QUALITY;
	lf.lfPitchAndFamily=VARIABLE_PITCH | FF_ROMAN;
	wcscpy(lf.lfFaceName, _T("MS Sans Serif") );

	pfont.CreateFontIndirect( &lf );		

	CDC BufferDC;
	CBitmap BufferBitmap, *OldBitmap;
	
	BufferDC.CreateCompatibleDC ( pDC );
	CFont *pOldFont = BufferDC.SelectObject(&pfont);
		
	SIZE  size;
	GetTextExtentPoint32( BufferDC.GetSafeHdc(), szString, wcslen(szString), &size );

	if( width != -1 )
		size.cx = width;
	else
		size.cx += 16;		
	
	BufferBitmap.CreateCompatibleBitmap ( pDC, size.cx, size.cy );
	OldBitmap=BufferDC.SelectObject ( &BufferBitmap );
	
	BufferDC.FillSolidRect ( 0, 0, size.cx, size.cy, 0 );		
	
	RECT rect;
	rect.left = 2;
	rect.top  = 0;
	rect.right = size.cx-1;
	rect.bottom = size.cy-1;

	BufferDC.SetTextColor(fontcolor);	
	BufferDC.DrawText(szString,&rect,DT_LEFT|DT_VCENTER|DT_SINGLELINE);

	if( szSecondString )
	{
		SIZE secondsize;
		GetTextExtentPoint32( BufferDC.GetSafeHdc(), szSecondString, wcslen(szSecondString), &secondsize );
		
		if( width != -1 )
			secondsize.cx = width;
		else
			secondsize.cx += 16;		

		rect.left = secondoffset;
		rect.top  = 0;
		rect.right = secondsize.cx-1;
		rect.bottom = secondsize.cy-1;

		BufferDC.DrawText(szSecondString,&rect,DT_LEFT|DT_VCENTER|DT_SINGLELINE);
	}
	
	BufferDC.SelectObject ( OldBitmap );

	Create ( size.cx, size.cy );
	GetDIBits ( pDC->m_hDC, HBITMAP(BufferBitmap), 0, size.cy, m_Bits, &(m_Info), DIB_RGB_COLORS ); 

	BufferDC.SelectObject(pOldFont);
	pfont.DeleteObject();

	return TRUE;
}
Exemplo n.º 17
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);
	DrawViewImage(pDC,m_ImageCenter,enMode_Centent);

	//绘画用户
	TCHAR szBuffer[32];
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

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

		//tagUserData *pUserData = new tagUserData;
		//strcpy( (char*)pUserData->szName, "dkjfdkfjdkfj" );
		//pUserData->cbUserStatus = US_READY;
		//wUserTimer = 10;
		//m_ImageLand.DrawImage(pDC,m_ptLand[i].x,m_ptLand[i].y);
		//m_wBombTime = 2;
		///////////////////////////////////////////////////////

		//绘画用户
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextAlign( ( ( i == 2 && ! m_bDeasilOrder ) || ( i == 0 && m_bDeasilOrder ) ) ? TA_RIGHT : TA_LEFT );
			pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
			DrawTextString( pDC, pUserData->szName, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_ptName[i].x,m_ptName[i].y );

			//剩余扑克
		//	if (i!=1)
			{
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("剩余:%d 张"),m_bCardCount[i]);
				DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_ptName[i].x,m_ptName[i].y+18 );
			}

			//其他信息
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData->wFaceID,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
		}
	}

	//叫分标志
	int nXImagePos,nImageWidth=m_ImageScore.GetWidth(),nImageHeight=m_ImageScore.GetHeight();
	for (WORD i=0;i<3;i++)
	{
		if ((m_bScore[i]!=0)||(m_bPass[i]==true))
		{
			if ( m_bPass[i]==true ) nXImagePos=m_ImageScore.GetWidth()*4/5;
			else if ( m_bScore[i]==255 ) nXImagePos=m_ImageScore.GetWidth()*3/5;
			else nXImagePos=(m_bScore[i]-1)*m_ImageScore.GetWidth()/5;
			
			m_ImageScore.DrawImage(pDC,m_ptScore[i].x,m_ptScore[i].y,nImageWidth/5,nImageHeight,nXImagePos,0);
		}
	}

	//庄家位置
	if (m_wLandUser!=INVALID_CHAIR)
	{
		//获取用户
		const tagUserData * pUserData=GetUserInfo(m_wLandUser);
		if (pUserData!=NULL)
		{
			//变量定义
			TCHAR szBuffer[64];

			//设置 DC
			pDC->SetTextAlign(TA_LEFT|TA_TOP);
			pDC->SetTextColor(RGB(250,250,250));

			//绘画信息
			m_ImageLand.DrawImage(pDC,m_ptLand[m_wLandUser].x,m_ptLand[m_wLandUser].y);
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("地主:%s"),pUserData->szName);
			pDC->TextOut(m_nXBorder+m_nXFace+10,m_nYBorder+8,szBuffer,lstrlen(szBuffer));

			//绘画头像
			DrawUserFace(pDC,pUserData->wFaceID,m_nXBorder+5,m_nYBorder+5,false);

			//叫牌分数
			LONG lScore=m_cbLandScore*m_lBaseScore;
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("分数:%ld 分"),lScore);
			DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_nXBorder+m_nXFace+10,m_nYBorder+25 );
		}
	}

	//绘画爆炸
	if (m_bBombEffect==true)
	{
		//加载资源
		CImageHandle HandleBombEffect(&m_ImageBombEffect);

		//绘画效果
		INT nImageHeight=m_ImageBombEffect.GetHeight();
		INT nImageWidth=m_ImageBombEffect.GetWidth()/BOMB_EFFECT_COUNT;
		m_ImageBombEffect.AlphaDrawImage(pDC,(nWidth-nImageWidth)/2,0,nImageWidth,nImageHeight,
			nImageWidth*(m_cbBombFrameIndex%BOMB_EFFECT_COUNT),0,RGB(255,0,255));
	}

	//炸弹倍数
	if (m_wBombTime>1)
	{
		//炸弹标志
		CImageHandle ImageHandle(&m_ImageBomb);
		m_ImageBomb.AlphaDrawImage(pDC,m_nXBorder+5,nHeight-m_nYBorder-m_ImageBomb.GetHeight()-5,RGB(255,0,255));

		//设置 DC
		pDC->SetTextColor(RGB(250,250,250));
		pDC->SetTextAlign(TA_LEFT|TA_TOP);

		//炸弹倍数
		TCHAR szBuffer[64];
		_snprintf(szBuffer,sizeof(szBuffer),TEXT("炸弹翻倍:%d"),m_wBombTime);
		DrawTextString( pDC, szBuffer, RGB( 255, 255, 255 ), RGB( 0, 0, 0 ), m_nXBorder+m_ImageBomb.GetWidth()+10,nHeight-m_nYBorder-20 );
	//	pDC->TextOut(m_nXBorder+m_ImageBomb.GetWidth()+10,nHeight-m_nYBorder-20,szBuffer,lstrlen(szBuffer));
	}

	//描述信息
	if (m_bLandTitle==true)
	{
		//创建资源
		CFont InfoFont;
		InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

		//设置 DC
		pDC->SetTextColor(RGB(201,229,133));
		pDC->SetTextAlign(TA_CENTER|TA_TOP);
		CFont * pOldFont=pDC->SelectObject(&InfoFont);

		//绘画信息
		pDC->TextOut(nWidth/2,200,"正等待用户叫分");

		//清理资源
		pDC->SelectObject(pOldFont);
		InfoFont.DeleteObject();
	}

	//托管标识
	for ( WORD wChairID = 0; wChairID < GAME_PLAYER; ++wChairID ) {
		
		const tagUserData * pUserData=GetUserInfo( wChairID );
		if ( pUserData == NULL ) m_bUserTrustee[ wChairID ] = false;

		if ( m_bUserTrustee[ wChairID ] ) {
			if ( wChairID == 1 )
				m_ImageUserTrustee.DrawImage( pDC, m_ptLand[ wChairID ].x + 40, m_ptLand[ wChairID ].y - 1 );
			else if ( wChairID == 0 && !m_bDeasilOrder || wChairID == 2 && m_bDeasilOrder )
				m_ImageUserTrustee.DrawImage( pDC, m_ptFace[ wChairID ].x + m_nXFace + 8, m_ptFace[ wChairID ].y + m_nYFace -
				m_ImageUserTrustee.GetHeight() + 3 );
			else 
				m_ImageUserTrustee.DrawImage( pDC, m_ptFace[ wChairID ].x - m_nXFace - 8, m_ptFace[ wChairID ].y + m_nYFace -
				m_ImageUserTrustee.GetHeight() + 3 );
		}
	}

	return;
}
Exemplo n.º 18
0
// ----------------------------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
 HRSRC   hResource;
 HGLOBAL resPoints;
 DWORD   resSize;
 LPVOID  rgnPoints;
 HRGN    hWindowRegion;
 static  CFont fntTitle;
 static  CFont fntDescr;
 static  HWND  hCloseButton = NULL;
 HDC     hdc;
 PAINTSTRUCT pt;
	
 switch (message) 
 {
  case WM_CREATE:		 
   hResource = FindResource(d_about.hInstance,d_about.d_lprgnname,ABOUT_STC_RGN_RESOURCE_TYPE);
   if (NULL==hResource) 
    AfxMessageBox(_T("Can't find resource!"),MB_OK|MB_ICONSTOP);

   resPoints = LoadResource(d_about.hInstance,hResource);
   if (NULL==resPoints)
    AfxMessageBox(_T("Can't load resource!"),MB_OK|MB_ICONSTOP);

   resSize = SizeofResource(d_about.hInstance,hResource);
   if (0==resSize)
    AfxMessageBox(_T("Size of resource = 0 !"),MB_OK|MB_ICONSTOP);

   rgnPoints = LockResource(resPoints);
   hWindowRegion = ExtCreateRegion(NULL,resSize,(RGNDATA*)rgnPoints);
   SetWindowRgn(hWnd,hWindowRegion,TRUE);

   hCloseButton = CreateWindowEx(NULL,_T("button"),_T("close"),
                WS_CHILD | (d_about.showCloseButton ? WS_VISIBLE : 0),
                280,186,45,16,hWnd,(HMENU)IDC_BUTTON_CLOSE,
				d_about.hInstance,NULL);

   if (d_about.modal)
    ::SetFocus(hCloseButton);

   fntDescr.CreateFont(
   12,                        // nHeight
   0,                         // nWidth
   0,                         // nEscapement
   0,                         // nOrientation
   FW_NORMAL,                 // nWeight
   FALSE,                     // bItalic
   FALSE,                     // bUnderline
   0,                         // cStrikeOut
   ANSI_CHARSET,              // nCharSet
   OUT_DEFAULT_PRECIS,        // nOutPrecision
   CLIP_DEFAULT_PRECIS,       // nClipPrecision
   DEFAULT_QUALITY,           // nQuality
   DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
   _T("Arial"));

   fntTitle.CreateFont(
   14,                        // nHeight
   0,                         // nWidth
   0,                         // nEscapement
   0,                         // nOrientation
   FW_NORMAL,                 // nWeight
   FALSE,                     // bItalic
   FALSE,                     // bUnderline
   0,                         // cStrikeOut
   ANSI_CHARSET,              // nCharSet
   OUT_DEFAULT_PRECIS,        // nOutPrecision
   CLIP_DEFAULT_PRECIS,       // nClipPrecision
   DEFAULT_QUALITY,           // nQuality
   DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
   _T("Arial"));

   SendMessage(hCloseButton,WM_SETFONT,(LPARAM)fntDescr.m_hObject,TRUE);

   if (d_about.autoClose > 0)
     SetTimer(hWnd, AUTOCLOSE_TIMER_ID, d_about.autoClose, NULL);
   break;
  case WM_LBUTTONDOWN:
   SendMessage(hWnd,WM_NCLBUTTONDOWN,HTCAPTION,lParam); 		
   break;
  case WM_COMMAND:
   if (LOWORD(wParam)==IDC_BUTTON_CLOSE)
    DestroyWindow(hWnd);
   break;
  case WM_DESTROY:
   fntTitle.DeleteObject();
   fntDescr.DeleteObject();
   //we again ready for create a new instance!
   is_instance = false;
   break;
  case WM_KILLFOCUS:
   if (d_about.modal) 
    if ((HWND)wParam!=hCloseButton)
     SetFocus(hWnd);
   break;
  case WM_PAINT:
   hdc = BeginPaint(hWnd,&pt);
   SetBkColor(hdc,RGB(0,0,0));
   //draw title
   SetTextColor(hdc,RGB(40,250,50));
   SelectObject(hdc,fntTitle.m_hObject);
   TextOut(hdc,195,16,d_about.about_product,_tcslen(d_about.about_product));
   //draw description
   SelectObject(hdc,fntDescr.m_hObject);
   SetTextColor(hdc,RGB(250,240,250));
   SetBkMode(hdc, TRANSPARENT);
   DrawText(hdc,d_about.about_description,-1,CRect(203,45,433,170),DT_EDITCONTROL |DT_WORD_ELLIPSIS);

   EndPaint(hWnd,&pt); 
   break;
  case WM_TIMER:
   ASSERT(KillTimer(hWnd, AUTOCLOSE_TIMER_ID));
   DestroyWindow(hWnd);
   break;
  default:
   return DefWindowProc(hWnd, message, wParam, lParam);
 }
 return 0;
}
Exemplo n.º 19
0
void ZoomBox_NcPaint(HWND hwnd, HRGN hrgn)
/************************************************************************/
{
	CRect  r, rTitle, rMenu, rCaption, rCookie;
	TCHAR Caption[80];


	GetWindowRect(hwnd,&r);
	r.OffsetRect(-r.left, -r.top);
	CalcTitleRect(hwnd,TRUE, rTitle);
	CalcSysMenuRect(hwnd,TRUE, rMenu);
	rCookie.SetRect(
		rMenu.left + SYS_COOKIE_OFFSET + 1,
		rMenu.top  + SYS_COOKIE_OFFSET + 1,
		rMenu.left + SYS_COOKIE_OFFSET + SYS_COOKIE_WIDTH,
		rMenu.top  + SYS_COOKIE_OFFSET + SYS_COOKIE_HEIGHT);

	// Exclude the Caption Bar area and Have default draw
    HDC hDC = ::GetDCEx(hwnd, hrgn,
	    DCX_USESTYLE | DCX_WINDOW | DCX_INTERSECTRGN | DCX_LOCKWINDOWUPDATE);
	int level = ::SaveDC(hDC);
	CRgn rgn1;
	CRgn rgn2;
	rCaption.UnionRect((LPRECT)&rTitle,(LPRECT)&rMenu);
	::ClientToScreen(hwnd,(LPPOINT)&rCaption);
	::ClientToScreen(hwnd,(LPPOINT)&rCaption.right);
	rgn1.FromHandle(hrgn);
	rgn2.CreateRectRgn(rCaption.left,rCaption.top,rCaption.right,rCaption.bottom);
	int ret = rgn2.CombineRgn(&rgn1,&rgn2,RGN_DIFF);
/*
ERROR		    0
NULLREGION	    1
SIMPLEREGION	    2
COMPLEXREGION	    3
*/
	DefWindowProc(hwnd, WM_NCPAINT, (WPARAM)(HRGN)(rgn2.GetSafeHandle()),
		(LPARAM)0L); 
	::RestoreDC(hDC,level);
	::ReleaseDC(hwnd,hDC);


	// Draw the title bar, sys menu cookie, and border	
	CWnd *pWnd = CWnd::FromHandle(hwnd);
	CDC *pDC = pWnd->GetWindowDC(); 
	if (!pDC)
    	return;
	
	CBrush TitleBrush(GetSysColor(COLOR_ACTIVECAPTION));
	CBrush FrameBrush(COLOR_BORDER);
	CBrush MenuBrush(COLOR_SYSMENU);
	CBrush CkBrush(COLOR_COOKIEFILL);
	CBrush CkBrushShadow(COLOR_SYSSHADOW);
	
	pDC->FillRect(rTitle, &TitleBrush);
	pDC->FillRect(rMenu,  &MenuBrush);
	
	pDC->FrameRect(rTitle,  &FrameBrush);
	pDC->FrameRect(r,       &FrameBrush);
	pDC->FrameRect(rMenu,   &FrameBrush);
	pDC->FrameRect(rCookie, &CkBrushShadow);
	rCookie.OffsetRect(-1, -1);
	pDC->FillRect(rCookie,  &CkBrush);
	pDC->FrameRect(rCookie, &FrameBrush);

	CFont fnt;
	int FntHeight = 12;
	if (fnt.CreateFont(FntHeight,0,0,0,FW_NORMAL,FALSE,FALSE,0,0,OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
		DEFAULT_PITCH|FF_DONTCARE|TMPF_TRUETYPE,NULL))
	{
		pDC->SelectObject(&fnt);
		pDC->SetBkMode(TRANSPARENT);
		pDC->SetTextColor(GetSysColor(COLOR_CAPTIONTEXT));
		if (::GetWindowText(hwnd,Caption,80) == 0)
			lstrcpy(Caption,_T("QuickZoom"));
		pDC->DrawText((LPCSTR)Caption,-1,&rTitle,DT_CENTER|DT_VCENTER);
		fnt.DeleteObject();
	}
	
	pWnd->ReleaseDC(pDC);
}
Exemplo n.º 20
0
void CLLTDlg::UpdateView(double Alpha)
{
	CClientDC dc(this); // device context for painting

	CDC dcMem;
	dcMem.CreateCompatibleDC(&dc);
	dcMem.SetBkMode(TRANSPARENT);

	CRect dcMemRect(0,0,m_IterRect.Width(), m_IterRect.Height());
	CBitmap bmb;
	bmb.CreateCompatibleBitmap(&dc,m_IterRect.Width(), m_IterRect.Height());
	CBitmap *pOldBitmap = dcMem.SelectObject(&bmb);

	CBrush FillBrush(GetSysColor(COLOR_3DFACE));
	dcMem.FillRect(&dcMemRect,&FillBrush);

	CRect BltRect(0,0,m_IterRect.Width(), m_IterRect.Height());
	m_IterGraph.DrawGraph(&dcMem, &BltRect,false);

	dcMem.SetTextAlign(TA_LEFT);
	if(IsBlackAndWhite())	dcMem.SetTextColor(0);
	else					dcMem.SetTextColor(RGB(150,150,150));

	CFont TFont;
	TFont.CreatePointFont(85, "Symbol");
	CFont* pOldFont = dcMem.SelectObject(&TFont);
	dcMem.TextOut(50,35,"(|Da|)");
	CFont MFont;
	MFont.CreatePointFont(85, "Arial");
	dcMem.SelectObject(&MFont);
	
	CString strong;
	strong.Format("max = %.4f", m_pIterCurve->y[m_pIterCurve->n-1]);

	dcMem.TextOut(80,35,strong);

	CFont CvFont;
	CvFont.CreateFont(18,0,0,0,FW_BOLD,FALSE,FALSE,0,
			ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
			DEFAULT_QUALITY, FF_SWISS+VARIABLE_PITCH, "Arial");

	dcMem.SelectObject(&CvFont);

	dcMem.SetBkMode(TRANSPARENT);
	CString Title;

	if(!m_bType4){
		Title.Format("Alpha = %.2f°", Alpha);
	}
	else{
		Title.Format(" Iterations for QInf = %.2f m/s", Alpha);
	}
	dcMem.TextOut(200,5,Title);

	if(m_State ==1){
		if(IsBlackAndWhite()){
			dcMem.SetTextColor(0);
		}
		else{
			dcMem.SetTextColor(RGB(0,150,0));
		}
		dcMem.TextOut(200,35,"CONVERGED !");
	}
	else if (m_State ==2){
		if(IsBlackAndWhite()) 	dcMem.SetTextColor(0);
		else dcMem.SetTextColor(RGB(255,0,0));
		dcMem.TextOut(200,35,"UNCONVERGED...");
	}


	dc.BitBlt(m_IterRect.left, m_IterRect.top, m_IterRect.Width(), m_IterRect.Height(),
			  &dcMem,0, 0, SRCCOPY);
	dcMem.SelectObject(pOldFont);
	dcMem.SelectObject(pOldBitmap);
	bmb.DeleteObject();
	CvFont.DeleteObject();
	TFont.DeleteObject();
	MFont.DeleteObject();
	FillBrush.DeleteObject();
}
Exemplo n.º 21
0
HRESULT CSTEditorDoc::GetPages (CStringArray &pages)
{
    TCHAR    szTempName[_MAX_PATH];
    TCHAR    szPath[_MAX_PATH];
    long lLinesPerPage;
    long lLineNum = 0;
    CDC      dcPrint;
    TEXTMETRIC tm;
    CFont Font;
    CFont * pOldFont;
    long lCharsPerLine = 80;

    if (FAILED(AttachPrinterDC(&dcPrint)))
    {
        return (E_FAIL);
    }

    dcPrint.m_bPrinting = TRUE;

    CRect rect;
    rect.SetRect( 0, 0, GetPageWidth (), GetPageHeight () );

    // printing

    lLinesPerPage = GetPrintLinesPerPage(&dcPrint);

    HDC hdcMeta = NULL;
    CDC dcMeta;

    for (LINEDESC * pLine = m_Edit.m_pLine; NULL != pLine; pLine = pLine->pNext)
    {
        bool bSuccess;
        CString strText;

        bSuccess = m_Edit.ExpandLine (pLine, strText);
        ASSERT (bSuccess);

        strText.TrimRight ();

        // if text line is empty make it a line with a single
        // blank character
        if (strText.IsEmpty())
        {
            strText = _T(" ");
        }

        while (!strText.IsEmpty())
        {

            if (hdcMeta == NULL)
            {
                VERIFY(GetTempPath(sizeof(szPath), szPath) != 0);
                VERIFY(GetTempFileName(szPath, _T("pst"), 0, szTempName) != 0);
                pages.Add( szTempName );

                CString strDesc;
                CString strAppl;
                TCHAR*   pBuf;

                strAppl = GetPathName();

                // read documentation of CreateEnhMetaFile() to understand the
                // formatting of this string
                strDesc.Format("STEditor %s Page %d ", strAppl, pLine->iLineNo);
                pBuf = strDesc.GetBuffer(0);
                pBuf[8] = 0;
                pBuf[strDesc.GetLength() - 1] = 0;
                strDesc.ReleaseBuffer();

                hdcMeta = ::CreateEnhMetaFile( dcPrint, szTempName, &rect, strDesc);

                if (!hdcMeta) 
                {
                    return (E_FAIL);
                }

                dcMeta.Attach(hdcMeta);
                dcMeta.m_bPrinting = TRUE;
                dcMeta.SetMapMode (MM_TEXT);

                pOldFont = SelectPrintFont(&dcMeta, &Font);
                dcMeta.GetTextMetrics(&tm);
                CSize tmSize(tm.tmAveCharWidth, tm.tmHeight);
                dcMeta.LPtoHIMETRIC(&tmSize);
                lCharsPerLine = GetPageWidth() / tmSize.cx;
            }

            dcMeta.TextOut(0, lLineNum * tm.tmHeight, strText.Left(lCharsPerLine));
            lLineNum++;
            if (strText.GetLength() > lCharsPerLine)
            {
                strText = strText.Mid(lCharsPerLine);
            }
            else
            {
                strText = _T("");
            }

            if (lLineNum >= lLinesPerPage)
            {
                lLineNum = 0;
                dcMeta.SelectObject(pOldFont);
                Font.DeleteObject();
                dcMeta.Detach();
                DeleteEnhMetaFile (CloseEnhMetaFile(hdcMeta));
                hdcMeta = NULL;
            }
        }
    }

    if (NULL != hdcMeta)
    {
        dcMeta.SelectObject(pOldFont);
        dcMeta.Detach();
        DeleteEnhMetaFile (CloseEnhMetaFile(hdcMeta));
        hdcMeta = NULL;
    }

    return (S_OK);
}
Exemplo n.º 22
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//变量定义
	CImageHandle HandleTitle(&m_ImageTitle);
	//CImageHandle HandleBarMid(&m_ImageBarMid);
	CImageHandle HandleBarLeft(&m_ImageBarLeft);
	CImageHandle HandleBarRight(&m_ImageBarRight);
	CImageHandle HandleGlodTable(&m_ImageGlodTable);
	CImageHandle HandleHeadBg(&m_ImageHeadBg);
	CImageHandle HandleTotal(&m_ImageTotal);
	//绘画背景
	//DrawViewImage(pDC,m_ImageBackGround,enMode_Centent);

	DrawViewImage(pDC,m_ImageBackGround,enMode_Spread);
	DrawViewImage(pDC,m_ImageGlodTable,enMode_Centent);
	
	
	//m_ImageGlodTable.BitBlt(pDC->m_hDC,(nWidth-m_ImageGlodTable.GetWidth())/2,(nHeight-m_ImageGlodTable.GetHeight())/2);

	//控制区域
	//m_ImageBarLeft.BitBlt(pDC->m_hDC,m_nXBorder,nHeight-m_ImageBarLeft.GetHeight()-m_nYBorder);
	//m_ImageBarMid.StretchBlt(pDC->m_hDC,m_nXBorder+m_ImageBarLeft.GetWidth(),nHeight-m_ImageBarMid.GetHeight()-m_nYBorder,nWidth-2*m_nXBorder-m_ImageBarLeft.GetWidth()-m_ImageBarRight.GetWidth(),m_ImageBarMid.GetHeight());
	//m_ImageBarRight.BitBlt(pDC->m_hDC,nWidth-m_nXBorder-m_ImageBarRight.GetWidth(),/*m_ImageBarRight.GetHeight()+*/m_nYBorder);
	m_ImageBarRight.AlphaDrawImage(pDC,nWidth-m_nXBorder-m_ImageBarRight.GetWidth(),m_nYBorder,RGB(255,0,255));
	m_ImageBarLeft.AlphaDrawImage(pDC,m_nXBorder,nHeight-m_ImageBarLeft.GetHeight()-m_nYBorder,RGB(255,0,255));
	//左上角
	//m_ImageTitle.BitBlt(pDC->m_hDC,m_nXBorder,m_nYBorder);
	m_ImageTitle.AlphaDrawImage(pDC,m_nXBorder+20,m_nYBorder+10,RGB(255,0,255));

	m_ImageTotal.AlphaDrawImage(pDC,nWidth/2-m_ImageTotal.GetWidth()/2,nHeight/2-m_ImageTotal.GetHeight()/2,RGB(255,0,255));
	//绘画用户
	WORD wUserTimer=0;
	TCHAR szBuffer[64];

	pDC->SetTextColor(RGB(255,255,0));
	for (WORD i=0;i<4;i++)
	{
		//变量定义
		const tagUserData * pUserData=GetUserInfo(i);
		if (pUserData!=NULL)
		{
			//m_ImageHeadBg.BitBlt(pDC->m_hDC,m_ptFace[i].x-2,m_ptFace[i].y-2);
			//用户名字
			pDC->SetTextAlign((i==1)?(TA_RIGHT|TA_TOP):(TA_LEFT|TA_TOP));
			pDC->TextOut(m_ptName[i].x,m_ptName[i].y,pUserData->szName,lstrlen(pUserData->szName));

			//用户金币
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("¥%ld"),pUserData->lScore);
			pDC->TextOut(m_ptName[i].x,m_ptName[i].y+16,szBuffer,lstrlen(szBuffer));

			//其他信息
			wUserTimer=GetUserTimer(i);
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);

		}
	}

	//游戏信息
	const UINT uDrawFormat=DT_END_ELLIPSIS|DT_CENTER|DT_SINGLELINE|DT_VCENTER;
	pDC->SetTextAlign(TA_LEFT|TA_TOP);
	pDC->SetTextColor(RGB(255,255,255));
	if (m_lMaxGold!=0) 
	{
		_snprintf(szBuffer,sizeof(szBuffer),TEXT("¥%ld"),m_lMaxGold);
		DrawText(pDC->GetSafeHdc(),szBuffer,lstrlen(szBuffer),CRect(91,25,167,40),uDrawFormat);
		//DrawText(pDC->GetSafeHdc(),szBuffer,lstrlen(szBuffer),CRect(86,28,162,43),uDrawFormat);
	}
	if (m_lBasicGold!=0) 
	{
		_snprintf(szBuffer,sizeof(szBuffer),TEXT("¥%ld"),m_lBasicGold);
		//DrawText(pDC->GetSafeHdc(),szBuffer,lstrlen(szBuffer),CRect(86,35,162,50),uDrawFormat);
		DrawText(pDC->GetSafeHdc(),szBuffer,lstrlen(szBuffer),CRect(91,47,167,62),uDrawFormat);
	}

	//绘画筹码
	LONG lTotalGold=0L;
	for (DWORD i=0;i<CountArray(m_GoldView);i++)
	{
		lTotalGold+=m_GoldView[i].GetGold();
		m_GoldView[i].DrawGoldView(pDC,m_GoldStation[i].x,m_GoldStation[i].y);
	}

	//总注信息
	if (lTotalGold!=0L)
	{
		CFont ViewFont;
		ViewFont.CreateFont(-24,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("楷体_GB2312"));
		CFont * pOldFont=pDC->SelectObject(&ViewFont);
		pDC->SetTextColor(RGB(0,0,250));
		pDC->SetTextAlign(TA_CENTER|TA_TOP);
		_snprintf(szBuffer,sizeof(szBuffer),TEXT("%ld"),lTotalGold);
		pDC->TextOut(nWidth/2,nHeight/2-12,szBuffer,lstrlen(szBuffer));

		pDC->SetTextColor(RGB(255,0,0));
		pDC->TextOut(nWidth/2+1,nHeight/2-12+1,szBuffer,lstrlen(szBuffer));
		pDC->TextOut(nWidth/2+1,nHeight/2-12-1,szBuffer,lstrlen(szBuffer));
		pDC->TextOut(nWidth/2+1,nHeight/2-12+0,szBuffer,lstrlen(szBuffer));
		pDC->TextOut(nWidth/2-1,nHeight/2-12+1,szBuffer,lstrlen(szBuffer));
		pDC->TextOut(nWidth/2-1,nHeight/2-12-1,szBuffer,lstrlen(szBuffer));
		pDC->TextOut(nWidth/2-1,nHeight/2-12+0,szBuffer,lstrlen(szBuffer));
		pDC->TextOut(nWidth/2+0,nHeight/2-12+1,szBuffer,lstrlen(szBuffer));
		pDC->TextOut(nWidth/2+0,nHeight/2-12-1,szBuffer,lstrlen(szBuffer));

		pDC->SelectObject(pOldFont);
		ViewFont.DeleteObject();
	}
	return;
}
Exemplo n.º 23
0
BOOL CMyDialog::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	//	BOOL bResult=CDialog::OnEraseBkgnd(pDC);
	if (!m_bHaveStoreBgDC)
	{
		CRect rect;
		GetClientRect(rect);
		m_bHaveStoreBgDC=TRUE;
		Color 	clrStart=Color(230,230,230);
		Color 	clrEnd=Color(255,255,255);
		
		m_StoreBgDC.DeleteDC();
		m_StoreBgDC.CreateCompatibleDC(pDC);
		CBitmap bmp;
		bmp.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
		CBitmap *pOldBmp=m_StoreBgDC.SelectObject(&bmp);
		Graphics myGraphics(m_StoreBgDC.m_hDC);	
		LinearGradientBrush linGrBrush(
			Rect(0,0,rect.Width(),rect.Height()),
			clrStart,
			clrEnd, 
			LinearGradientModeVertical);
		myGraphics.FillRectangle(&linGrBrush, 0,31,rect.Width(),rect.Height()); 
		
		Color clrCaptionStart(219,219,220);
		Color clrCaptionEnd(190,192,193);
		LinearGradientBrush linGrBrush1(
			Rect(0,0,rect.Width(),30),
			clrCaptionStart,
			clrCaptionEnd, 
			LinearGradientModeVertical);
		myGraphics.FillRectangle(&linGrBrush1, 0,0,rect.Width(),30); 
		
		DrawCloseButton(&m_StoreBgDC,DTS_NORMAL);
		DrawMinButton(&m_StoreBgDC,DTS_NORMAL);
		
		CPen MarkPen(PS_SOLID,1,RGB(158,158,158));
		CBrush *pOldBrush=(CBrush *)m_StoreBgDC.SelectStockObject(NULL_BRUSH);
		CPen *pOldPen=m_StoreBgDC.SelectObject(&MarkPen);
		m_StoreBgDC.RoundRect(m_rcMin.left-1,m_rcMin.top-5,m_rcClose.right+1,m_rcClose.bottom+1,5,5);	
		
		CPen penBorder(PS_SOLID,1,RGB(150,150,150));
		m_StoreBgDC.SelectObject(&penBorder);	
		m_StoreBgDC.MoveTo(0,30);
		m_StoreBgDC.LineTo(rect.Width(),30);
		m_StoreBgDC.MoveTo(m_rcClose.left-1,1);
		m_StoreBgDC.LineTo(m_rcClose.left-1,21);
		rect.DeflateRect(0,0,1,1);
		m_StoreBgDC.RoundRect(rect,CPoint(7,5));
		m_StoreBgDC.SelectObject(pOldPen);
		m_StoreBgDC.SelectObject(pOldBrush);
		
		
		rect.bottom=30;
		HICON hIcon=GetIcon(FALSE);
		if (hIcon)   //画Icon
		{
			DrawIconEx(m_StoreBgDC.m_hDC,5,7,hIcon,16,16,0,NULL,DI_NORMAL | DI_COMPAT);
			rect.left+=21;
			m_rcIcon.SetRect(5,7,21,23);
		}
		CString str;
		GetWindowText(str);
		if (str!="") //写标题
		{
			rect.left+=5;
			rect.top+=4;
			m_StoreBgDC.SetBkMode(TRANSPARENT);
			COLORREF OldClr=m_StoreBgDC.SetTextColor(RGB(50,50,50));
			CFont font;
			font.CreatePointFont(100,"雅黑",&m_StoreBgDC);
			CFont *pOldFont=m_StoreBgDC.SelectObject(&font);
			m_StoreBgDC.DrawText(str,rect,DT_VCENTER | DT_SINGLELINE);
			m_StoreBgDC.SelectObject(pOldFont);
			m_StoreBgDC.SetTextColor(OldClr);
			font.DeleteObject();
		}
		/*		m_StoreBgDC.SelectObject(pOldBmp);*/
		bmp.DeleteObject();
	}
	CRect rect;
	GetClientRect(rect);
	pDC->BitBlt(0,0,rect.Width(),rect.Height(),&m_StoreBgDC,0,0,SRCCOPY);
	return TRUE;
}
Exemplo n.º 24
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageViewCenter,enMode_Spread);
	DrawViewImage(pDC,m_ImageViewBack,enMode_Centent);

	//绘画用户
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

#ifdef _DEBUG
		////测试代码
		//tagUserData Obj;
		//Obj.cbUserStatus = US_READY;
		//Obj.lScore = 999999999;
		//_sntprintf( Obj.szName,sizeof(Obj.szName),TEXT("用户的名字"));
		//wUserTimer = i+1;
		//pUserData = &Obj;
		////庄家标志
		//CImageHandle ImageHandleBanker(&m_ImageBanker);
		//m_ImageBanker.AlphaDrawImage(pDC,m_PointBanker[i].x,m_PointBanker[i].y,m_ImageBanker.GetWidth(),m_ImageBanker.GetHeight(),0,0,RGB(255,0,255));

#endif
	
		//绘画用户
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextAlign((i==1)?TA_RIGHT:TA_LEFT);
			pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));

			//用户金币
			TCHAR szBuffer[64]=TEXT("");
			LONGLONG lLeaveScore=pUserData->lScore-m_lTableScore[i];
			_snprintf(szBuffer,sizeof(szBuffer),TEXT(" [%s]"/*"[¥%I64d]"*/),/*lLeaveScore*/NumToString(lLeaveScore));
			int TempX=0;
			int TempY=0;
			if(i%2==1)
			{
				TempX=35;
				if(i==3)TempX*=-1;
				TempY=30;
			}

			//获取用户名长度
			CSize szStr;
			int iLen=lstrlen(pUserData->szName);
			GetTextExtentPoint(pDC->GetSafeHdc(), pUserData->szName, iLen, &szStr);

			//用户名字
			DrawTextString(pDC,pUserData->szName,RGB(255,255,255),RGB(0,0,0),m_ptName[i].x-60,m_ptName[i].y+TempY);
			//用户金币
			DrawTextString(pDC,szBuffer,RGB(230,215,90),RGB(0,0,0),m_ptName[i].x-60+szStr.cx,m_ptName[i].y+TempY);

			//其他信息
			if (wUserTimer!=0)
			{
				//if(m_bCallUser!=0xff)DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
				//else if (pUserData->cbUserStatus==US_PLAY)
				//if(pUserData->cbUserStatus<=US_SIT/*GS_FREE*/)
				if (wUserTimer<60)
					DrawUserTimer(pDC,nWidth/2,nHeight/2-25,wUserTimer);
				else
				{
					DrawUserTimer(pDC,nWidth/2,nHeight/2-25,0);
				}
				//else DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			}
			if (pUserData->cbUserStatus==US_READY) 
			{
				//DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
				m_pngNiuNum.DrawImage(pDC, m_ptReady[i].x,m_ptReady[i].y, m_pngNiuNum.GetWidth()/13, m_pngNiuNum.GetHeight(), (m_pngNiuNum.GetWidth()/13)*11, 0);
			}
			//DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE,32,32);
		}
	}

	//等待下注
	if (m_bInvest==true)
	{
		//创建资源
// 		CFont InfoFont;
// 		InfoFont.CreateFont(-24,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("楷体_GB2312"));
// 
// 		//设置 DC
// 		pDC->SetTextAlign(TA_CENTER|TA_TOP);
// 		CFont * pOldFont=pDC->SelectObject(&InfoFont);
// 
// 		//绘画信息
// 		TCHAR zsInfo[128]=TEXT("");
// 		_sntprintf(zsInfo,sizeof(zsInfo),TEXT("等待闲家下注"));
// 		DrawTextString(pDC,zsInfo,RGB(250,200,40),RGB(0,0,0),nWidth/2,nHeight/2);
// 
// 		//清理资源
// 		pDC->SelectObject(pOldFont);
// 		InfoFont.DeleteObject();
		int x = (nWidth-m_pngWaitBet.GetWidth())/2;
		m_pngWaitBet.DrawImage(pDC, x, nHeight/2);
	}

	//特殊牌型
	if (m_bUserAction==true)
	{
		//创建资源
		CFont InfoFont;
		InfoFont.CreateFont(-16,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("楷体_GB2312"));

		//设置 DC
		pDC->SetTextColor(RGB(250,200,40));
		pDC->SetTextAlign(TA_CENTER|TA_TOP);
		CFont * pOldFont=pDC->SelectObject(&InfoFont);

		//绘画信息
		pDC->TextOut(nWidth/2,nHeight/2+150,"特殊牌型,系统自动为你配牌 ^-^");

		//清理资源
		pDC->SelectObject(pOldFont);
		InfoFont.DeleteObject();
	}

	//等待摊牌
	if (m_bOpenCard==true)
	{
// 		//创建资源
// 		CFont InfoFont;
// 		InfoFont.CreateFont(-24,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("楷体_GB2312"));
// 
// 		//设置 DC
// 		pDC->SetTextColor(RGB(250,200,40));
// 		pDC->SetTextAlign(TA_CENTER|TA_TOP);
// 		CFont * pOldFont=pDC->SelectObject(&InfoFont);
// 
// 		//绘画信息
// 		TCHAR zsInfo[128]=TEXT("");
// 		_sntprintf(zsInfo,sizeof(zsInfo),TEXT("等待玩家摊牌"));
// 		DrawTextString(pDC,zsInfo,RGB(250,200,40),RGB(0,0,0),nWidth/2,nHeight/2);
// 
// 		//清理资源
// 		pDC->SelectObject(pOldFont);
// 		InfoFont.DeleteObject();
	}

	//等待叫庄
	if(m_bCallUser!=0xff && (m_bCallUser!=2 || m_bLookOnUser))
	{
		CImageHandle HandleOx(&m_ImageWaitCall);
		int y=m_SendEndingPos[m_bCallUser].y+10;
		int x=nWidth/2 - m_ImageWaitCall.GetWidth()/2;
		if(m_bCallUser==1)x=nWidth/2+273-120;
		else if(m_bCallUser==3)x=nWidth/2-273-30;
		else if(m_bCallUser==0)y+=30;
// 		m_ImageWaitCall.AlphaDrawImage(pDC,x,y,m_ImageWaitCall.GetWidth(),
// 			m_ImageWaitCall.GetHeight(),0,0,RGB(255,0,255));

		m_pngWaitCall.DrawImage(pDC, x,y);
	}

	//庄家信息
	if (m_wBankerUser!=INVALID_CHAIR)
	{
		const tagUserData * pUserData=GetUserInfo(m_wBankerUser);
		if (pUserData!=NULL)
		{
			//庄家标志
			//CImageHandle ImageHandleBanker(&m_ImageBanker);
			//m_ImageBanker.AlphaDrawImage(pDC,m_PointBanker[m_wBankerUser].x,m_PointBanker[m_wBankerUser].y,m_ImageBanker.GetWidth(),m_ImageBanker.GetHeight(),0,0,RGB(255,0,255));
			m_pngBanker.DrawImage(pDC, m_PointBanker[m_wBankerUser].x,m_PointBanker[m_wBankerUser].y);
		}
	}

	//绘画积分
	for (BYTE i=0;i<GAME_PLAYER;i++)
	{
		const tagUserData * pUserData=GetUserInfo(i);
		if (pUserData!=NULL &&(m_lTableScore[i]!=0L || m_bShowSocre[i]))
		{
			int iPos=1;
			if(m_bShowSocre[i])
			{
				if(m_lTableScore[i]>0L)iPos=0;
				else if(m_lTableScore[i]<=0L)iPos=2;
			}
			CImageHandle HandleScore(&m_ImageScore);
			m_ImageScore.AlphaDrawImage(pDC,m_ptJeton[i].x,m_ptJeton[i].y,m_ImageScore.GetWidth()/3,
				m_ImageScore.GetHeight(),m_ImageScore.GetWidth()/3*iPos,0,RGB(255,0,255));

			//创建字体
			CFont ViewFont;
			ViewFont.CreateFont(-16,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("宋体"));

			//设置 DC
			//pDC->SetTextAlign(TA_CENTER);
			pDC->SetTextAlign(TA_LEFT);
			CFont * pOldFont=pDC->SelectObject(&ViewFont);

			//绘画信息
			TCHAR tc[NAME_LEN]=TEXT("");
			_sntprintf(tc,sizeof(tc),TEXT("%I64d"),m_lTableScore[i]);
			//nWidth/2,nHeight/2
			//DrawTextString(pDC,tc,RGB(247,231,8),RGB(255,255,255),nWidth/2+10,m_ptJeton[i].y+15);
			CRect rcScore;
			rcScore.left = m_ptJeton[i].x-50;
			rcScore.top = m_ptJeton[i].y;
			rcScore.bottom = rcScore.top+m_ImageScore.GetHeight();
			rcScore.right = rcScore.left + m_ImageScore.GetWidth()/3+100;

			//DrawTextString(pDC, tc, RGB(247,231,8),RGB(255,255,255), rcScore);
			pDC->SetTextColor(RGB(247,231,8));
			pDC->DrawText(tc,lstrlen(tc),&rcScore,DT_VCENTER|DT_CENTER|DT_SINGLELINE|DT_END_ELLIPSIS);
			//pDC->Draw3dRect(rcScore, RGB(255,255,255),RGB(255,255,255));

			//清理资源
			pDC->SelectObject(pOldFont);
			ViewFont.DeleteObject();
		}
	}

	//显示摊牌标志
	for (BYTE i=0;i<GAME_PLAYER;i++)
	{
		if (m_bOpenCardUser[i]==TRUE)
		{
			//创建字体
			CFont ViewFont;
			ViewFont.CreateFont(-20,0,0,0,700,0,0,0,134,3,2,1,1,TEXT("华文彩云"));

			//设置 DC
			pDC->SetTextAlign(TA_LEFT);
			CFont * pOldFont=pDC->SelectObject(&ViewFont);

			//绘画信息
// 			TCHAR tc[NAME_LEN]=TEXT("");
// 			_snprintf(tc,sizeof(tc),"摊");
			INT x,y;
			if(i==0)
			{
				x = m_ptJeton[i].x+20;
				y = m_ptJeton[i].y+40;
			}
			else if(i==1)
			{
				x = m_ptJeton[i].x+97;
				y = m_ptJeton[i].y-55;
			}
			else if(i==2)
			{
				x =m_ptJeton[i].x+20;
				y = m_ptJeton[i].y-60;
			}
			else 
			{
				x = m_ptJeton[i].x-37;
				y = m_ptJeton[i].y-55;
			}
			//DrawTextString(pDC,tc,RGB(250,128,56),RGB(0,0,0),x,y);
			m_pngNiuNum.DrawImage(pDC, x, y, m_pngNiuNum.GetWidth()/13, m_pngNiuNum.GetHeight(), (m_pngNiuNum.GetWidth()/13)*12, 0);


			//清理资源
			pDC->SelectObject(pOldFont);
			ViewFont.DeleteObject();
		}
	}

	//绘画扑克
	if (m_SendCardItemArray.GetCount()>0)
	{
		//变量定义
		CImageHandle HandleCard(&m_ImageCard);
		tagSendCardItem * pSendCardItem=&m_SendCardItemArray[0];

		//获取大小
		int nItemWidth=m_ImageCard.GetWidth()/13;
		int nItemHeight=m_ImageCard.GetHeight()/5;

		//绘画扑克
		int nXPos=m_SendCardPos.x-nItemWidth/2;
		int nYPos=m_SendCardPos.y-nItemHeight/2+10;
		m_ImageCard.AlphaDrawImage(pDC,nXPos,nYPos,nItemWidth,nItemHeight,nItemWidth*2,nItemHeight*4,RGB(255,0,255));
	}

	//显示点数
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		if(m_bOxValue[i]!=0xff)
		//if((m_bOxValue[i]=OX_THREE_SAME) || true)
		{
			if(m_bShow || i==2)
			{
				INT nxSp = m_pngNiuNum.GetWidth()/13;
				if(m_bOxValue[i]!=0)
				{
					CImageHandle HandleOxValue(&m_ImageOxValue);
					INT nXpt = (i%2!=0)?(m_ptValue[i].x-80):(m_CardControl[i].GetCardPos().x-2-m_pngNiuNum.GetWidth()/13);
					INT nypt = m_ptValue[i].y;
// 					m_ImageOxValue.AlphaDrawImage(pDC,nXpt,nypt,
// 						m_ImageOxValue.GetWidth(),m_ImageOxValue.GetHeight(),0,0,RGB(255,0,255));

					if(m_bOxValue[i]>=OX_THREE_SAME)
					{
						pDC->SetTextColor(RGB(0,0,0));
						pDC->SetTextAlign(TA_LEFT);
						TCHAR tCh[64]= {0};
						_snprintf(tCh, 64, TEXT("花牛"));
						if(m_bOxValue[i]==OX_THREE_SAME)_sntprintf(tCh,64,TEXT("葫芦"));
						else if(m_bOxValue[i]==OX_FOUR_SAME)_sntprintf(tCh,64,TEXT("炸弹"));
						pDC->TextOut(nXpt+33,nypt+10,tCh,lstrlen(tCh));
					}	
					else if(m_bOxValue[i]==10)
					{
// 						CImageHandle HandleDoulbeOx(&m_ImageDoulbeOx);
// 						m_ImageDoulbeOx.AlphaDrawImage(pDC,nXpt+33,nypt+6,
// 							m_ImageDoulbeOx.GetWidth(),m_ImageDoulbeOx.GetHeight(),0,0,RGB(255,0,255));
						INT nXpt = m_ptValue[i].x;
						INT nypt = m_ptValue[i].y;
						m_pngNiuNum.DrawImage(pDC, nXpt-((i!=1)?30:5), nypt+1, nxSp, m_pngNiuNum.GetHeight(), nxSp*10, 0);
					}	
					else if(m_bOxValue[i]<10)
					{
// 						CImageHandle HandleNumber(&m_ImageNumber);
// 						m_ImageNumber.AlphaDrawImage(pDC,nXpt+35,nypt+7,
// 							m_ImageNumber.GetWidth()/9,m_ImageNumber.GetHeight(),
// 							m_ImageNumber.GetWidth()/9*((int)m_bOxValue[i]-1),0,RGB(255,0,255));
						m_pngNiuNum.DrawImage(pDC, nXpt, nypt+6, nxSp, m_pngNiuNum.GetHeight(), nxSp*((int)m_bOxValue[i]), 0);
					}
				}
				else if(m_bOxValue[i]==0)
				{				
 					INT nXpt = m_ptValue[i].x;
 					INT nypt = m_ptValue[i].y;
// 					CImageHandle HandleOxValueZero(&m_ImageOxValueZero);
// 					m_ImageOxValueZero.AlphaDrawImage(pDC,nXpt+((i!=1)?31:5),nypt+1,
// 						m_ImageOxValueZero.GetWidth(),m_ImageOxValueZero.GetHeight(),0,0,RGB(255,0,255));
					m_pngNiuNum.DrawImage(pDC ,nXpt-((i!=1)?30:5), nypt+1, nxSp, m_pngNiuNum.GetHeight(), 0, 0);
				}
			}
		}
	}
	return;
}
Exemplo n.º 25
0
void CBitmapListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	if (lpDrawItemStruct->CtlType==ODT_LISTVIEW)
	{
		//TCHAR sz[100];
		//wsprintf(sz,"%d",(lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top));
		//MessageBox(sz);
		//获取数据
		UINT iWidth=0;
		TCHAR szBuffer[30];
		memset(szBuffer,0,sizeof(szBuffer));
		CDC * pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
		UserItemStruct * pUserItem=(UserItemStruct *)GetItemData(lpDrawItemStruct->itemID);
		CFont font;
		font.CreateFont(-12,0,0,0,700,NULL,NULL,NULL,134,3,2,1,2,TEXT("宋体"));
		
		CFont *pOldFont = pDC->SelectObject(&font);	///< Modified by zxd 20100709 旧字体保存下来。

		//设置颜色
//		COLORREF crTextColor,crBackColor;
		bool bSelect=(lpDrawItemStruct->itemState&ODS_SELECTED)||(lpDrawItemStruct->itemState&ODS_FOCUS);
		//GetDrawColor(crTextColor,crBackColor,pUserItem,0,bSelect);
		//pDC->SetBkColor(crBackColor);
		//pDC->SetTextColor(crTextColor);
		pDC->SetBkMode(TRANSPARENT);
		//绘画信息
		CSize TextSize;
		CRect rect1;
		TCHAR szname[300];
		for (int i=0;i<m_ListHeader.GetItemCount();i++)
		{
			int iTemp=GetColumnWidth(i);
			TextSize=pDC->GetTextExtent(szBuffer,lstrlen(szBuffer));
			GetItemText(lpDrawItemStruct->itemID,i,szBuffer,sizeof(szBuffer));
			CRect TextRect(lpDrawItemStruct->rcItem.left+iWidth,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.left+iWidth+iTemp,lpDrawItemStruct->rcItem.bottom);
			CGameImageHelper help(&m_itembk);
			help.BitBlt(pDC->GetSafeHdc(),TextRect.left,TextRect.top);
			//头像
			rect1=m_rlog;
			rect1.OffsetRect(TextRect.left,TextRect.top);
			CGameImage log;
			wsprintf(szname,".\\image\\log\\roomlistlog%d.bmp",pUserItem->GameUserInfo.bLogoID);
			//lstrcpy(szname,".\\image\\log\\log1.bmp");
			log.SetLoadInfo(szname,CGameImageLink::m_bAutoLock);
			CGameImageHelper helper(&log);
			//AFCStretchImage(pDC,rect1.left,rect1.top,rect1.Width(),rect1.Height(),helper,0,0,log.GetWidth(),log.GetHeight(),log.GetPixel(1,1));
			helper.BitBlt(pDC->GetSafeHdc(),rect1.left,rect1.top);
			helper.CloseGDIHandle();
			//名字
			rect1=m_rname;
			rect1.OffsetRect(TextRect.left,TextRect.top);
			lstrcpy(szname,pUserItem->GameUserInfo.nickName);
			DrawText(pDC->GetSafeHdc(),szname,lstrlen(szname),rect1,DT_CENTER|DT_VCENTER);
			//等级
			lstrcpy(szname,m_pGetOrderFun(pUserItem->GameUserInfo.dwPoint,0));
			rect1=m_rorder;
			rect1.OffsetRect(TextRect.left,TextRect.top);
			DrawText(pDC->GetSafeHdc(),szname,lstrlen(szname),rect1,DT_CENTER|DT_VCENTER);
			//金币
			lstrcpy(szname,m_sztitle);
			rect1=m_rcoin;
			rect1.OffsetRect(TextRect.left,TextRect.top);
			DrawText(pDC->GetSafeHdc(),szname,lstrlen(szname),rect1,DT_CENTER|DT_VCENTER);
			//经验值
			wsprintf(szname,"%d",pUserItem->GameUserInfo.dwPoint-GetNormalOrderBasePoint(pUserItem->GameUserInfo.dwPoint));
			rect1=m_rcoinc;
			rect1.OffsetRect(TextRect.left,TextRect.top);
			DrawText(pDC->GetSafeHdc(),szname,lstrlen(szname),rect1,DT_CENTER|DT_VCENTER);
			//赢
			wsprintf(szname,"赢 %d",pUserItem->GameUserInfo.uWinCount);
			rect1=m_rwin;
			rect1.OffsetRect(TextRect.left,TextRect.top);
			DrawText(pDC->GetSafeHdc(),szname,lstrlen(szname),rect1,DT_CENTER|DT_VCENTER);
			//输
			wsprintf(szname,"输 %d",pUserItem->GameUserInfo.uLostCount);
			rect1=m_rloss;
			rect1.OffsetRect(TextRect.left,TextRect.top);
			DrawText(pDC->GetSafeHdc(),szname,lstrlen(szname),rect1,DT_CENTER|DT_VCENTER);
			//桌号
			if(pUserItem->GameUserInfo.bDeskNO!=255&&m_uComType!=TY_MATCH_GAME)
			{
				wsprintf(szname,"%d\n号\n桌",pUserItem->GameUserInfo.bDeskNO+1);
				rect1=m_rdesk;
				rect1.OffsetRect(TextRect.left,TextRect.top);
				DrawText(pDC->GetSafeHdc(),szname,lstrlen(szname),rect1,DT_CENTER|DT_VCENTER);
			}

			
			if(bSelect)
				PatBlt(pDC->GetSafeHdc(),TextRect.left,TextRect.top,TextRect.Width(),TextRect.Height(),DSTINVERT);
/*
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&TextRect,DT_LEFT|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);
			if (TextSize.cx<iTemp) 
			{
				pDC->FillSolidRect(lpDrawItemStruct->rcItem.left+iWidth+TextSize.cx,lpDrawItemStruct->rcItem.top,
					iTemp-TextSize.cx,lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top,crBackColor);
			}
			iWidth+=iTemp;*/
		}

		/// {{Added by zxd 20100709 释放GDI资源
		pDC->SelectObject(pOldFont);
		font.DeleteObject();
		/// Added by zxd 20100709 释放GDI资源}}
	}
	return;	
}
Exemplo n.º 26
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageViewCenter,enMode_Centent);

	//人物句柄
	CImageHandle ImageHumanHandle(&m_ImageHuman);

	//获取大小
	int nItemWidth=m_ImageHuman.GetWidth()/8;
	int nItemHeight=m_ImageHuman.GetHeight()/2;

	//扑克句柄
	CImageHandle ImageCardHandle(&m_ImageCard);

	//扑克大小
	int nCardWidth=m_ImageCard.GetWidth()/13;
	int nCardHeight=m_ImageCard.GetHeight()/5;

	//D句柄
	CImageHandle ImageDHandle(&m_ImageD);

	//D大小
	int nDWidth = m_ImageD.GetWidth();
	int nDHeight = m_ImageD.GetHeight();

	//扑克掩图
	CImageHandle ImageCardMaskHandle(&m_ImageCardMask);

	//掩图大小
	int nCardMaskWidth = m_ImageCardMask.GetWidth();
	int nCardMaskHeight = m_ImageCardMask.GetHeight();

	//绘画用户
	if(!m_bReset)
	{
		for (WORD i=0;i<GAME_PLAYER;i++)
		{
			//绘制人物
			if(m_wUserGender[i] == 2)//男
			{
				m_ImageHuman.AlphaDrawImage(pDC,m_ptHuman[i].x,m_ptHuman[i].y,nItemWidth,nItemHeight,nItemWidth*i,0,RGB(255,0,255));
			}
			else if(m_wUserGender[i] == 1)//女
			{
				m_ImageHuman.AlphaDrawImage(pDC,m_ptWomen[i].x,m_ptWomen[i].y,nItemWidth,nItemHeight,nItemWidth*i,nItemHeight,RGB(255,0,255));
			}
		}
	}

	//绘画用户
	if(m_bShowUser==FALSE)return ;
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);

#ifdef _DEBUG
		//tagUserData Obj;
		//Obj.cbGender = 0;
		//_sntprintf( Obj.szName,sizeof(Obj.szName),TEXT("用户的名字"));
		//Obj.lScore = 10000;
		//Obj.cbUserStatus = US_READY;
		//m_wUserPost[i] = i;
		//pUserData = &Obj;
		//wUserTimer = 10;
#endif

		//绘画用户
		if (pUserData!=NULL)
		{
			WORD wUserId = m_wUserPost[i];
			pDC->SetTextColor((wUserTimer>0)?RGB(0,250,0):RGB(0,220,0));

			//绘制人物
			if(pUserData->cbGender == 0)
				m_ImageHuman.AlphaDrawImage(pDC,m_ptHuman[wUserId].x,m_ptHuman[wUserId].y,nItemWidth,nItemHeight,nItemWidth*wUserId,0,RGB(255,0,255));
			else
				m_ImageHuman.AlphaDrawImage(pDC,m_ptWomen[wUserId].x,m_ptWomen[wUserId].y,nItemWidth,nItemHeight,nItemWidth*wUserId,nItemHeight,RGB(255,0,255));

			//绘制举手
			if (pUserData->cbUserStatus==US_READY)
				DrawUserReady(pDC,m_ptReady[wUserId].x,m_ptReady[wUserId].y);

			//绘制时间
			if (wUserTimer>0)
			{
				DrawUserTimer(pDC,m_ptTimer[wUserId].x,m_ptTimer[wUserId].y,wUserTimer);
				if(wUserTimer%2==0)
				{
					CImageHandle ImageArrowheadHandle(&m_ImageArrowhead);
					int wPost = (wUserId+2)%8;
					int iAddY=0,iAddX=0;
					if(wUserId==0 || wUserId==1)
					{
						iAddY=25;
						//iAddX=10;
					}
					else if(wUserId==2)
					{
						iAddX=-40;
					}
					else if(wUserId==3||wUserId==4)
					{
						wPost = 6;
						iAddY=-45;
						iAddX=-10;
					}
					else if(wUserId==5)
					{
						iAddY=-45;
						//iAddX=10;
					}
					else if(wUserId==6)
					{
						iAddY=5;
						iAddX=35;
					}
					else if(wUserId==7)
					{
						iAddY=25;
						iAddX=10;
					}
					m_ImageArrowhead.AlphaDrawImage(pDC,m_ptTimer[wUserId].x+iAddX,m_ptTimer[wUserId].y+iAddY,
						m_ImageArrowhead.GetWidth()/8,m_ImageArrowhead.GetHeight(),
						m_ImageArrowhead.GetWidth()/8*wPost,0,RGB(255,0,255));
				}
			}

			//绘制D
			if(m_wDUser != INVALID_CHAIR)
			{
				m_ImageD.AlphaDrawImage(pDC,m_ptD[m_wDUser].x,m_ptD[m_wDUser].y,nDWidth,nDHeight,0,0,RGB(255,0,255));
			}

			//绘制小扑克
			if (pUserData->cbUserStatus!=US_READY)
				m_SmallCardControl[wUserId].DrawCardControl(pDC);

			m_CardControl[wUserId].DrawCardControl(pDC,m_bGameEnd);

			if(m_lTableScore[wUserId]>0)
			{
				m_GoldView[wUserId].DrawGoldView(pDC,m_ptJetton[wUserId].x,m_ptJetton[wUserId].y,true);
			}
		}

		//用户扑克
		m_CardControl[i].DrawCardControl(pDC,m_bGameEnd);

		//中心扑克
		m_CenterCardControl.DrawCardControl(pDC,m_bGameEnd);
	}

	//绘制中心筹码
	if(m_lCenterScore >0)
	{
		m_CenterGoldView.DrawGoldView(pDC,m_ptCenterJetton.x,m_ptCenterJetton.y,true,true,(BYTE)m_wDUser);
	}

	//绘画扑克
	for (WORD i=0;i<GAME_PLAYER+1;i++)
	{
		////绘制小扑克
		//if(i<GAME_PLAYER)
		//{
		//	m_SmallCardControl[i].DrawCardControl(pDC);
		//}

		//筹码移动
		if(m_MoveGoldView[i].GetGold()>0 && i<GAME_PLAYER)
		{
			m_MoveGoldView[i].DrawGoldView(pDC,m_JettonStatus[i].ptCourse.x,m_JettonStatus[i].ptCourse.y,true);
		}

		//小扑克
		if(m_CardStatus[i].GetCount()==0)continue;
		tagCardStatus * pCardStatus = &(m_CardStatus[i].GetAt(0));
		if(pCardStatus->wMoveCount>0)
		{
			//小扑克
			m_SmallCardControl[i].DrawOneCard(pDC,0,pCardStatus->ptCourse.x,pCardStatus->ptCourse.y);			
		}
	}

	//绘画用户
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		const tagUserData * pUserData=GetUserInfo(i);
		//绘画用户
		if (pUserData!=NULL)
		{
			WORD wUserId = m_wUserPost[i];

			//绘画框架
			CImageHandle ImageFrameHandle(&m_ImageUserFrame);
			m_ImageUserFrame.AlphaDrawImage(pDC,m_ptName[wUserId].x,m_ptName[wUserId].y,
				m_ImageUserFrame.GetWidth()/8,m_ImageUserFrame.GetHeight(),
				m_ImageUserFrame.GetWidth()/8*wUserId,0,RGB(255,0,255));

			CFont ViewFont;
			ViewFont.CreateFont(-15,0,0,0,400,0,0,0,134,3,2,1,1,TEXT("Arial"));
			CFont *pOldFont=pDC->SelectObject(&ViewFont);

			CSize rcSize(103,30);
			CRect rcName(m_ptName[wUserId],rcSize);
			pDC->SetBkMode(TRANSPARENT);
			pDC->SetTextColor(RGB(255,255,255));
			pDC->DrawText(pUserData->szName,lstrlen(pUserData->szName),&rcName,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);

			//用户金币
			CRect rcName1(m_ptName[wUserId].x,m_ptName[wUserId].y+20,m_ptName[wUserId].x+108,m_ptName[wUserId].y+50);
			pDC->SetTextColor(RGB(255,255,4));
			TCHAR szBuffer[128]=TEXT("");
			LONG lLeaveScore=pUserData->lScore - ((m_lTotalScore[wUserId]>0)?m_lTotalScore[wUserId]:0L);
			if(lLeaveScore<0)lLeaveScore=pUserData->lScore;

			//加千数点
			LONG lTempCount = lLeaveScore;
			GetGlodString(lTempCount,szBuffer);

			pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcName1,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);
			pDC->SelectObject(pOldFont);
			ViewFont.DeleteObject();	
		}
	}

	//坐下按钮
	if(m_wMyIsLookOn!=INVALID_CHAIR)
	{
		//查找空位
		for (WORD i=0;i<GAME_PLAYER;i++)
		{
			const tagUserData * pUserData=GetUserInfo(i);
			WORD wUserId = m_wUserPost[i];
			//坐下按钮
			if (pUserData==NULL)
			{
				m_btSitDown[wUserId].ShowWindow(SW_SHOW);
			}
			else
			{
				m_btSitDown[wUserId].ShowWindow(SW_HIDE);
			}
		}
	}

	return;
}
Exemplo n.º 27
0
void CGelView::DrawGel(CDC* pDC, CRect rcBounds) 
{
	char tBuff[128];
    
    CBrush bBrush;
	bBrush.CreateSolidBrush( RGB(255,255,255) );
	pDC->FillRect( &rcBounds, &bBrush );
	pDC->SetBkColor( RGB(255,255,255) );

	CSize docSize = GetGelSize();

	double ypi = pDC->GetDeviceCaps(LOGPIXELSY);
	double xpi = pDC->GetDeviceCaps(LOGPIXELSX);

	int x = (int)((double)docSize.cx/100.0 * xpi);
	int y = (int)((double)docSize.cy/100.0 * ypi);

	int xoff = rcBounds.TopLeft().x;
	int yoff = rcBounds.TopLeft().y;

	int YSpace = (int)(ypi / 24.0);
	int XSpace = (int)(xpi / 24.0);

	// Lets draw graph always ...
	//
	CFont fontTmp;
	CFont* pOldFont = SelectDocFont(pDC, fontTmp, 900);

	CPen nPen( PS_SOLID, m_LineWidth, RGB(0,0,0) );
    CPen* oPen = pDC->SelectObject(&nPen);


	CSize fontSize = pDC->GetTextExtent( "X", 1 );
	int NamesHeight = 0;
	POSITION gPos = m_listGel.GetHeadPosition();
	while ( gPos != NULL ) {
		SGel *pSGel = (SGel *)m_listGel.GetNext(gPos);
		CString strName = pSGel->Sequence->GetTitle();
		strName = strName.Left(10);

		CSize fontSize = pDC->GetTextExtent( strName, strName.GetLength() );
		int iHeight = fontSize.cx;
		if ( iHeight > NamesHeight ) NamesHeight = iHeight;

	}


//	int xborder = (int)((double)x * .05);

  	_snprintf( tBuff, 127, "%d", m_MaxY );	// = "1.0";
	CSize tstrsz;
	tstrsz = pDC->GetTextExtent( tBuff, strlen(tBuff) );
	int xborder = tstrsz.cx + XSpace;

	int yborder = (int)(xpi / 24.0);

	yborder += m_LineWidth;


	pDC->MoveTo(xoff + (xborder), yoff + (NamesHeight + YSpace - m_LineWidth) );
	pDC->LineTo(xoff + (xborder),yoff + (y - yborder));
	pDC->LineTo(xoff + (x - XSpace),yoff + (y - yborder));
	pDC->LineTo(xoff + (x - XSpace),yoff + ( NamesHeight + YSpace - m_LineWidth ));
	pDC->LineTo(xoff + (xborder ),yoff + (NamesHeight + YSpace - m_LineWidth ));

	int GraphWidth = (x - XSpace) - xborder;


	int drl = 1;
	while ( drl < m_MinY ) {
		if ( drl * 10 > m_MinY ) break;
		drl = drl * 10;
	}
	double YRange = m_MaxY - (double)drl + 1;

	double dblYMult = (double)y - (yborder + NamesHeight + YSpace);


	
	if ( m_listGel.GetCount() != 0 ) {

		int GelCount = m_listGel.GetCount();
		int dWidth = GraphWidth - ( GelCount * m_LineWidth * 2 );
		int BandWidth = dWidth / GelCount;

		int Band = 0;

		gPos = m_listGel.GetHeadPosition();
		while ( gPos != NULL ) {
			SGel *pSGel = (SGel *)m_listGel.GetNext(gPos);
			CString strName = pSGel->Sequence->GetTitle();
			strName = strName.Left(10);

			double dblXVal = (Band * BandWidth) + (Band * m_LineWidth * 2) - (m_LineWidth * 2);

			pDC->ExtTextOut( 
				1 + xoff + ((int)dblXVal + xborder) + ( BandWidth / 2 ) - ( fontSize.cx / 2 ),
				yoff + (NamesHeight + YSpace - m_LineWidth - 2), 
				ETO_CLIPPED, CRect ( xoff, yoff, xoff + x, yoff + y ), 
				strName, strName.GetLength(), NULL
			);

			Band++;

			int wdrl = drl;
			int inc = drl;
			while ( wdrl < m_MaxY ) {

				double dblYVal = 1.0 - (log (double( wdrl - drl + 1)) / log(YRange));


				dblYVal *= dblYMult;
				int tyloc = yoff + (NamesHeight + YSpace + (int)dblYVal - 1);

				pDC->MoveTo(
					1 + xoff + ((int)dblXVal + BandWidth + xborder + m_LineWidth+ m_LineWidth), 
					tyloc);
				pDC->LineTo(
					1 + xoff + ((int)dblXVal + BandWidth + xborder + m_LineWidth+ m_LineWidth + m_LineWidth), 
					tyloc);
				pDC->LineTo(
					1 + xoff + ((int)dblXVal + BandWidth + xborder + m_LineWidth+ m_LineWidth), 
					tyloc);


				wdrl += inc;
				if ( wdrl == inc * 10 ) {
					inc = inc * 10;
				}


			}


		}

		pDC->SelectObject( pOldFont );
		fontTmp.DeleteObject();
		pOldFont = SelectDocFont(pDC, fontTmp, 0);

		int yinc = ((y - yborder) - (NamesHeight + YSpace ))/4;

		pDC->MoveTo(xoff + (xborder),yoff + ( NamesHeight + YSpace ));
		pDC->LineTo(xoff + (xborder - XSpace),yoff + ( NamesHeight + YSpace ));
		pDC->LineTo(xoff + (xborder),yoff + ( NamesHeight + YSpace ));


  		_snprintf( tBuff, 127, "%d", m_MaxY );	// = "1.0";
		CSize tstrsz;
		tstrsz = pDC->GetTextExtent( tBuff, strlen(tBuff) );
		// pDC->LPtoDP( &tstrsz );

		pDC->ExtTextOut( 
			xoff + (xborder - XSpace - tstrsz.cx), 
			yoff + (NamesHeight + YSpace) - tstrsz.cy,  
			ETO_CLIPPED, CRect ( xoff, yoff, xoff + x, yoff + y ), 
			tBuff, strlen(tBuff), NULL 
		);




		int wdrl = drl;
		int inc = drl;
		while ( wdrl < m_MaxY ) {

			double dblYVal = 1.0 - (log (double( wdrl - drl + 1)) / log(YRange));


			dblYVal *= dblYMult;
			int tyloc = yoff + (NamesHeight + YSpace + (int)dblYVal - 1);

			pDC->MoveTo(xoff + (xborder),tyloc);
			pDC->LineTo(xoff + (xborder - XSpace),tyloc);
			pDC->LineTo(xoff + (xborder),tyloc);

			if ( wdrl == inc || wdrl == inc *5 ) {
				pDC->MoveTo(xoff + (xborder),tyloc);
				pDC->LineTo(xoff + (xborder - XSpace),tyloc);
				pDC->LineTo(xoff + (xborder),tyloc);
				
				_snprintf( tBuff, 127, "%d", wdrl );	// = ".75";
				tstrsz = pDC->GetTextExtent( tBuff, strlen(tBuff) );

				pDC->ExtTextOut( 
					xoff + (xborder - XSpace - tstrsz.cx), 
					tyloc -(tstrsz.cy/2),  
					ETO_CLIPPED, CRect ( xoff, tyloc-(tstrsz.cy/2), xoff + x, (tyloc -(tstrsz.cy/2)) + y ), 
					tBuff, strlen(tBuff), NULL 
				);
			}

			wdrl += inc;
			if ( wdrl == inc * 10 ) {
				inc = inc * 10;
			}
		}

		// For assumed Y Scale = 0 - 1.0
		// Create a red pen.
		pDC->SelectObject( oPen );
		nPen.DeleteObject();
		nPen.CreatePen( PS_SOLID, m_LineWidth, RGB(255,0,0) );
		oPen = pDC->SelectObject(&nPen);

		Band = 0;

		gPos = m_listGel.GetHeadPosition();
		while ( gPos != NULL ) {
			SGel *pSGel = (SGel *)m_listGel.GetNext(gPos);

			double dblXVal = (Band * BandWidth) + (Band * m_LineWidth * 2);

			int FragCount = pSGel->arrGelLoc.GetSize();

			for ( int i=0; i < FragCount; ++i ) {
				
				double ss = pSGel->arrGelLoc[i] / 100000000.0;
				double dblYVal = 1.0 - (log( (ss * YRange) - drl + 1) / log(YRange));

				dblYVal *= dblYMult;

				pDC->MoveTo( 
					1 + xoff + ((int)dblXVal + xborder), 
					yoff + (NamesHeight + YSpace + (int)dblYVal - 1)
				);
				pDC->LineTo( 
					1 + xoff + ((int)dblXVal + BandWidth + xborder) - (m_LineWidth * 2),
					yoff + (NamesHeight + YSpace +  (int)dblYVal - 1)
				);
				pDC->LineTo( 
					1 + xoff + ((int)dblXVal + xborder), 
					yoff + (NamesHeight + YSpace + (int)dblYVal - 1)
				);

			}

			Band++;
		}

	}

	pDC->SelectObject( oPen );
	nPen.DeleteObject();



	pDC->SelectObject( pOldFont );
	fontTmp.DeleteObject();


}
Exemplo n.º 28
0
void KSMsgDrawer::DisplayMessages(CDC * pDC,const CRect & client)
{
	if(!m_showMessage)
		return;
	// 设置字体
	LOGFONT lf;
	memset(&lf,0,sizeof lf);
	lf.lfCharSet = GB2312_CHARSET;
	strcpy(lf.lfFaceName,m_fontName);
	lf.lfHeight = m_fontSize;
	lf.lfWeight = FW_BOLD;
//	lf.lfWeight = FW_MEDIUM;
	
	CFont font;
	CFont *oldFont;
	font.CreateFontIndirect(&lf);
	oldFont = pDC->SelectObject(&font);
	// 如果只有一行就居中
	int line_top = (m_displayMsgList.size() == 1) ? client.Height() / 2 :
		client.Height() / 3;
	int last_line = 1;

	for(cstr_vector::iterator i = m_displayMsgList.begin();
		i != m_displayMsgList.end();++i)
	{
		cstring_msg msg = (*i).second;
		int lineno = msg.GetLineno();
		if( lineno <= 0)
			continue;

		CString msg_str = msg.GetMsg();
		if(msg.GetSizeOffset() != 0)
		{
			pDC->SelectObject(oldFont);						// 新添加将老字体资源获得
			font.DeleteObject();
			lf.lfHeight = m_fontSize + msg.GetSizeOffset();
			font.CreateFontIndirect(&lf);
			//pDC->SelectObject(&font);						// 隐藏掉
			oldFont = pDC->SelectObject(&font);				// 把新的字体资源添加进来
		}
		CSize size = pDC->GetTextExtent(msg_str);
		RECT textRect;
		if (0 == m_MsgDlgflag)
		{
			textRect.left = client.Width() / 5;
 			textRect.right = client.Width();
			m_drawFormat = DT_LEFT;
		}
		else if (1 == m_MsgDlgflag)
		{
			textRect.left = (client.Width() - size.cx) / 2;
			if(textRect.left < 1)
				textRect.left = 1;
			textRect.right = textRect.left + size.cx;
			if (textRect.right >= client.right )
				textRect.right = client.right - 1;
			m_drawFormat = DT_CENTER;
		}
		else if (2 == m_MsgDlgflag)
		{
			textRect.left = client.Width() / 5;
			textRect.right = client.Width();
// 			if (client.right - textRect.left < size.cx)
// 			{
// 				textRect.left = client.right - size.cx;
// 			}
// 			textRect.right = textRect.left + size.cx;
// 			if (textRect.right >= client.right)
// 			{
// 				textRect.right = client.right - 1;
// 			}
			m_drawFormat = DT_RIGHT;
		}
		else
		{
			// 这个位置因为m_MsgDlgflag没有赋值将不会显示图像
		}
		textRect.top = line_top + (lineno - last_line) * size.cy;
		textRect.bottom = client.bottom;
		pDC->DrawText(msg_str,&textRect,m_drawFormat|DT_SINGLELINE);	
		last_line = msg.GetLineno();
		line_top = textRect.top + size.cy / 2 ;
	}
	pDC->SelectObject(oldFont);
}	
Exemplo n.º 29
0
// Print (or preview) a single page
void CHexEditView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
	ASSERT(print_offset_.cx >= 0 && print_offset_.cy >= 0);
	pDC->SetMapMode(print_map_mode_);
	int u_scale = pDC->GetDeviceCaps(LOGPIXELSX); // units scaling (pixels/inch)
	if (theApp.print_units_ == CHexEditApp::PRN_CM)
		u_scale = int(u_scale/2.54);

	CRect rct;                              // Encloses all incl. header/footer - ie nothing is printed outside this box
	CRect margin_rct;                       // Smaller box based on margins - does not include header/footer
	CString ss;                             // String to display at top of page

	// Work out text height of the (printer) font
	pDC->SelectObject(print_font_);
	TEXTMETRIC tm;
	pDC->GetTextMetrics(&tm);
	int text_height = tm.tmHeight + tm.tmExternalLeading;

	// Work out size of the page
	int vert_res = pDC->GetDeviceCaps(VERTRES);
	int horz_res = pDC->GetDeviceCaps(HORZRES);
	if (vert_res < horz_res/5)                // May be lines of text not pixels (Eg Text Only driver)
		vert_res *= text_height;              // xxx should be device units not logical

	// Work out where the margins are
	margin_rct.top = LONG(theApp.top_margin_*u_scale);
	margin_rct.left = LONG(theApp.left_margin_*u_scale);
	margin_rct.bottom = vert_res - LONG(theApp.bottom_margin_*u_scale);
	margin_rct.right  = horz_res - LONG(theApp.right_margin_*u_scale);
	pDC->DPtoLP(&margin_rct);

	// Work out where to print the header and footer
	rct.top = LONG(theApp.header_edge_*u_scale);
	rct.left = LONG(theApp.left_margin_*u_scale);
	rct.bottom = vert_res - LONG(theApp.footer_edge_*u_scale);
	rct.right  = horz_res - LONG(theApp.right_margin_*u_scale);

	// Note we can't use ConvertFromDP here as this is for printer not screen
	pDC->DPtoLP(&rct);

	pDC->SetBkMode(TRANSPARENT);
	if (theApp.print_watermark_)
	{
		// Work out angle of diagonal from bottom left to top right
		ASSERT(rct.Height() != 0 && rct.Width() != 0);  // else we get divide by zero error
		double diag = (int)sqrt((double)(rct.Height()*rct.Height()) + rct.Width()*rct.Width());
		double angle = asin(rct.Height()/diag);

		// Create a large font at the angle of the diagonal
		int fangle = int(angle * 1800 / 3.141592 /*M_PI*/);   // convert diag angle to tenth of degrees from X-axis
		CFont fontWatermark;
		fontWatermark.CreateFont(rct.Height()/10, 0, fangle, fangle, FW_BOLD, 0, 0, 0,
								 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
								 DEFAULT_PITCH | FF_SWISS, _T("Arial"));
		CFont * pSaved = pDC->SelectObject(&fontWatermark);

		// Create the text
		CString str = create_header(theApp.watermark_, pInfo->m_nCurPage);

		// Get length of text then work out how far from the bottom page of the corner should the text start
		double d = (diag - pDC->GetTextExtent(str).cx)/2;  // distance along diag of start of text
		int x = int(d * cos(angle));
		int y = int(d * sin(angle));

		pDC->SetTextColor(RGB(208, 208, 208));          // light grey
		pDC->SetTextAlign(TA_BASELINE);
		pDC->TextOut(x, rct.Height() - y, str);

		pDC->SetTextAlign(TA_TOP);
		(void)pDC->SelectObject(pSaved);
		fontWatermark.DeleteObject();
	}

	pDC->SetTextColor(RGB(0,0,0));          // Display headers/footers in black

	int left, mid=1, right;
	if (theApp.even_reverse_ && pInfo->m_nCurPage%2 == 0)
		left = 2, right = 0;
	else
		left = 0, right = 2;

	if (rct.top - text_height > margin_rct.top)  // Note y values are always -ve down in printer map mode
	{
		// Get normal header unless using diff header for 1st page and its the first page
		CString strHeader;
		if (theApp.diff_first_header_ && pInfo->m_nCurPage == 1)
			strHeader = theApp.first_header_;
		else
			strHeader = theApp.header_;

		// Print the 3 parts of the header
		AfxExtractSubString(ss, strHeader, left, '|');
		pDC->DrawText(create_header(ss, pInfo->m_nCurPage), &rct, DT_LEFT | DT_TOP | DT_NOPREFIX | DT_SINGLELINE);

		AfxExtractSubString(ss, strHeader, mid, '|');
		pDC->DrawText(create_header(ss, pInfo->m_nCurPage), &rct, DT_CENTER | DT_TOP | DT_NOPREFIX | DT_SINGLELINE);

		AfxExtractSubString(ss, strHeader, right, '|');
		pDC->DrawText(create_header(ss, pInfo->m_nCurPage), &rct, DT_RIGHT | DT_TOP | DT_NOPREFIX | DT_SINGLELINE);
	}

	if (rct.bottom + text_height < margin_rct.bottom)  // Note y values are -ve down
	{
		// Get normal footer unless using diff footer for 1st page and it's the first page
		CString strFooter;
		if (theApp.diff_first_footer_ && pInfo->m_nCurPage == 1)
			strFooter = theApp.first_footer_;
		else
			strFooter = theApp.footer_;

		// Print the 3 parts of the footer
		AfxExtractSubString(ss, strFooter, left, '|');
		pDC->DrawText(create_header(ss, pInfo->m_nCurPage), &rct, DT_LEFT | DT_BOTTOM | DT_NOPREFIX | DT_SINGLELINE);

		AfxExtractSubString(ss, strFooter, mid, '|');
		pDC->DrawText(create_header(ss, pInfo->m_nCurPage), &rct, DT_CENTER | DT_BOTTOM | DT_NOPREFIX | DT_SINGLELINE);

		AfxExtractSubString(ss, strFooter, right, '|');
		pDC->DrawText(create_header(ss, pInfo->m_nCurPage), &rct, DT_RIGHT | DT_BOTTOM | DT_NOPREFIX | DT_SINGLELINE);
	}

	if (theApp.print_hdr_)
	{
		// Print column headings
		rct = margin_rct + CSize(print_offset_.cx, 0);
		pDC->DrawText("Address", &rct, DT_LEFT | DT_TOP | DT_NOPREFIX | DT_SINGLELINE);
		for (int ii = 0; ii < rowsize_; ++ii)
		{
			char buf[10];
			if (!display_.hex_addr)            // Probably showing dec addresses and/or line numbers so show dec hdr
				sprintf(buf, "%2d", ii%100);
			else if (theApp.hex_ucase_)
				sprintf(buf, "%02X", ii%0x100);
			else
				sprintf(buf, "%02x", ii%0x100);
			if (!display_.vert_display && display_.hex_area)
				pDC->TextOut(rct.left + hex_pos(ii, print_text_width_), rct.top, buf, 2);
			if (display_.vert_display || display_.char_area)
				pDC->TextOut(rct.left + char_pos(ii, print_text_width_, print_text_width_w_), rct.top, buf+1, 1);
		}
	}

	// Draw margins in print preview
	if (pInfo != NULL && pInfo->m_bPreview && pDC->m_hAttribDC != NULL)
	{
		CPen pen(PS_DOT, 0, RGB(0,0,0));
		CPen* ppen = pDC->SelectObject(&pen);
		pDC->MoveTo(-30000, margin_rct.top);
		pDC->LineTo(30000, margin_rct.top);
		pDC->MoveTo(margin_rct.left, -30000);
		pDC->LineTo(margin_rct.left, 30000);
		pDC->MoveTo(-30000, margin_rct.bottom);
		pDC->LineTo(30000, margin_rct.bottom);
		pDC->MoveTo(margin_rct.right, -30000);
		pDC->LineTo(margin_rct.right, 30000);
		pDC->SelectObject(ppen);
	}

	if (theApp.print_box_)
	{
		// Work out width of total printed text
		CSize size;

		rct = margin_rct + CSize(print_offset_.cx, 0);

		if (display_.char_area)
			size.cx = char_pos(rowsize_, print_text_width_, print_text_width_w_);
		else
			size.cx = hex_pos(rowsize_, print_text_width_);
		size.cy = 0;

		// Draw a box around it
		CPen pen(PS_SOLID, 0, RGB(0,0,0));
		CPen* ppen = pDC->SelectObject(&pen);
		pDC->MoveTo(rct.left - print_text_width_, rct.top);
		pDC->LineTo(rct.left + size.cx + print_text_width_, rct.top);
		pDC->LineTo(rct.left + size.cx + print_text_width_, rct.bottom);
		pDC->LineTo(rct.left - print_text_width_, rct.bottom);
		pDC->LineTo(rct.left - print_text_width_, rct.top);

#if 0
		// Draw line between address and hex areas
		size.cx = hex_pos(0, print_text_width_);
		size.cy = 0;
		pDC->MoveTo(rct.left + size.cx - print_text_width_, rct.top);
		pDC->LineTo(rct.left + size.cx - print_text_width_, rct.bottom);

		// Draw line between areas
		if (display_.hex_area && display_.char_area)
		{
			size.cx = hex_pos(rowsize_, print_text_width_);
			size.cy = 0;
			pDC->MoveTo(rct.left + size.cx - print_text_width_/2, rct.top);
			pDC->LineTo(rct.left + size.cx - print_text_width_/2, rct.bottom);
		}
#endif
		pDC->SelectObject(ppen);
	}

	// Do this last so pen changes etc do not affect header, footer etc drawing
	CScrView::OnPrint(pDC, pInfo);          // Calls OnDraw to print rest of page
}
Exemplo n.º 30
0
//绘画函数
void CPropertyItem::OnPaint()
{
	CPaintDC dc(this); 

	//绘画标题
	DrawCaption(&dc);

	//获取位置
	CRect ClientRect;
	GetClientRect(&ClientRect);
	int nXExcursion=GetXExcursionPos();
	int nYExcursion=GetYExcursionPos();

	//绘画背景
	COLORREF Color = /*RGB(0,51,102)*/RGB(115,181,239);
	dc.FillSolidRect(nXExcursion,nYExcursion,ClientRect.Width()-2*nXExcursion,4,Color);
	dc.FillSolidRect(nXExcursion,ClientRect.Height()-8,ClientRect.Width()-2*nXExcursion,7,Color);
	dc.FillSolidRect(nXExcursion,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color);
	dc.FillSolidRect(ClientRect.Width()-nXExcursion-12,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color);

	//绘画边框
	DrawBorder(&dc);

	//道具图片
	CBitmap Bitmap;

	//加载图片
	AfxSetResourceHandle(CPropertyBar::m_pPropertyBar->m_ReshInstance);
	if ( Bitmap.LoadBitmap(CPropertyBar::m_pPropertyBar->m_PropertyViewImage.uPropertyFormer[m_nPropertyID]) )
	{
		//创建资源
		CDC dcMem;
		dcMem.CreateCompatibleDC(&dc);
		CBitmap *pOldBitmap = dcMem.SelectObject(&Bitmap);

		//绘画图片
		BITMAP bm;
		Bitmap.GetBitmap(&bm);
		dc.TransparentBlt(10, 28+5, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, bm.bmWidth, bm.bmHeight,RGB(255,255,255)); 
		
		//是否资源
		dcMem.SelectObject(pOldBitmap);
		Bitmap.DeleteObject();
		dcMem.DeleteDC();
	}
	AfxSetResourceHandle(GetModuleHandle(NULL));

	//获取位置
	CRect rcStaticName, rcStaticDes;
	GetDlgItem(IDC_PROPERTY_NAME)->GetWindowRect(rcStaticName);
	GetDlgItem(IDC_PROPERTY_DESCRIBE)->GetWindowRect(rcStaticDes);
	ScreenToClient(&rcStaticName);
	ScreenToClient(&rcStaticDes);

	//设置内容
	CRect rcPropertyName(rcStaticName.right+3, rcStaticName.top, rcStaticName.right+200, rcStaticName.bottom+100);
	CRect rcPropertyDes(rcStaticDes.right+3, rcStaticDes.top, rcStaticDes.right+200, rcStaticDes.bottom+70);
	if(m_nPropertyID>=PROP_MEMBER_1)rcPropertyDes.right+=30;

	//创建字体
	CFont font;
	VERIFY(font.CreateFont(
		15,                        // nHeight
		0,                         // nWidth
		0,                         // nEscapement
		0,                         // nOrientation
		FW_NORMAL,                 // nWeight
		FALSE,                     // bItalic
		FALSE,                     // bUnderline
		0,                         // cStrikeOut
		ANSI_CHARSET,              // nCharSet
		OUT_DEFAULT_PRECIS,        // nOutPrecision
		CLIP_DEFAULT_PRECIS,       // nClipPrecision
		DEFAULT_QUALITY,           // nQuality
		DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
		"Arial"));                 // lpszFacename

	//设置属性
	dc.SetBkMode(TRANSPARENT);
	CFont* def_font = dc.SelectObject(&font);
	
	//描述信息
	UINT nFormat = DT_LEFT | DT_TOP | DT_WORDBREAK;
	dc.DrawText(g_PropertyDescribe[m_nPropertyID].szName, rcPropertyName, nFormat);
	dc.DrawText(g_PropertyDescribe[m_nPropertyID].szDescribe, rcPropertyDes, nFormat);

	//删除资源
	dc.SelectObject(def_font);
	font.DeleteObject();
}