コード例 #1
0
ファイル: duPie.cpp プロジェクト: blueantst/dulib
void WINAPI duPie::DrawObject(HDC hDC)
{
	duRect rcPie;
	GetRect(&rcPie);
	rcPie.OffsetRect(-rcPie.left, -rcPie.top);
	
	Graphics *gs = new Graphics(hDC);
	Color clrAll = Color(255, GetRValue(m_clrAll), GetGValue(m_clrAll), GetBValue(m_clrAll));
	Color clrPercent = Color(255, GetRValue(m_clrPercent), GetGValue(m_clrPercent), GetBValue(m_clrPercent));
	
	SolidBrush allBrush(clrAll);
	SolidBrush percentBrush(clrPercent);
	Rect rect(3, 3, rcPie.Width() - 6, rcPie.Height() - 6); //½«±ýͼÇøÓòËõС3¸öÏñËØ£¬¾ÍÄÜ»­Ô²ÁË
	
	gs->SetSmoothingMode(SmoothingModeHighQuality);
	gs->FillPie(&allBrush, rect, m_fPercent * 360.0f / 100.0f +270.0f, 360.0f);

	gs->SetSmoothingMode(SmoothingModeHighQuality);
	gs->FillPie(&percentBrush, rect, 270.0f, m_fPercent * 360.0f / 100.0f);
	
	delete gs;
}
コード例 #2
0
ファイル: UIPie.cpp プロジェクト: the7day/py-ui4win
	void CPieUI::PaintBkImage(HDC hDC)
	{
		//MoveToEx(hDC, (int) m_coordinate.cx + m_cXY.cx, (int) m_coordinate.cy + m_cXY.cy, (LPPOINT) NULL); 
		//AngleArc(hDC, m_coordinate.cx + m_cXY.cx, m_coordinate.cy + m_cXY.cy, m_dwRadius, m_dwStartAngle, m_dwEndAngle);
		//MoveToEx(hDC, (int) m_coordinate.cx + m_cXY.cx, (int) m_coordinate.cy + m_cXY.cy, (LPPOINT) NULL); 

		Bitmap* mBtmap;
		Graphics* graphics;

		mBtmap = new Bitmap(m_dwRadius * 2 + 1, m_dwRadius * 2 + 1);
		graphics = Graphics::FromImage(mBtmap);

		graphics->SetSmoothingMode(SmoothingModeHighQuality);

		SolidBrush crGradient(Color(GetRValue(m_dwColor), GetGValue(m_dwColor), GetBValue(m_dwColor)));
		Pen pnHighLight(Color(GetRValue(m_dwColor), GetGValue(m_dwColor), GetBValue(m_dwColor)));

		graphics->FillPie(&crGradient, 
			RectF((REAL)0, 
			(REAL)0, 
			(REAL)m_dwRadius * 2, 
			(REAL)m_dwRadius * 2), 
			(REAL)m_dwStartAngle, 
			(REAL)m_dwEndAngle);
		//graphics->DrawPie(&pnHighLight, 
		//	RectF((REAL)0, 
		//	(REAL)0, 
		//	(REAL)m_dwRadius * 2, 
		//	(REAL)m_dwRadius * 2), 
		//	(REAL)m_dwStartAngle, 
		//	(REAL)m_dwEndAngle);
		delete graphics;
		graphics = NULL;

		Graphics gr(hDC);
		//CachedBitmap* btmp = new CachedBitmap(mBtmap, &gr);

		gr.DrawImage(mBtmap, (int)(m_rcItem.left + m_coordinate.cx - m_dwRadius), m_rcItem.top + m_coordinate.cy - m_dwRadius);	
		if (mBtmap){
			delete mBtmap;
			mBtmap = NULL;
		}
	}