Exemplo n.º 1
0
void CDuiColorPicker::OnPaint( CDCHandle dc )
{
	CRect rcClient;
	GetClient(&rcClient);
	ALPHAINFO ai;
	CGdiAlpha::AlphaBackup(dc,rcClient,ai);
	dc.FillSolidRect(&rcClient,m_crCur);
	dc.DrawEdge(&rcClient, BDR_RAISEDINNER, BF_RECT);
	CGdiAlpha::AlphaRestore(dc,ai);
}
Exemplo n.º 2
0
LRESULT CLayerOptionsDlg::OnDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	UINT idCtl = (UINT) wParam;             // control identifier 
	LPDRAWITEMSTRUCT lpDrawItemStruct = (LPDRAWITEMSTRUCT) lParam; // item-drawing information 

	CDCHandle pDC = lpDrawItemStruct->hDC;
	CRect rc = lpDrawItemStruct->rcItem;

	if (idCtl == IDC_LAYER_COLOR)
	{
		pDC.DrawEdge(&rc, (lpDrawItemStruct->itemState & ODS_SELECTED)? EDGE_SUNKEN : EDGE_RAISED, BF_RECT | BF_ADJUST);

		rc.InflateRect(-1,-1);
		pDC.FillSolidRect(&rc, m_color);
	}
	else
	{
		int w = 12;
		int h = 12;

		int id = lpDrawItemStruct->itemID;

		if (id >= 0)
		{
			COLORREF	ref;

			if (lpDrawItemStruct->itemState & ODS_SELECTED)
				ref = ::GetSysColor(COLOR_HIGHLIGHT);
			else
				ref = ::GetSysColor(COLOR_WINDOW);

		//	pDC->FillSolidRect(rc.left+1, rc.top+1, rc.Width()-1, rc.Height()-1, ref);
			pDC.FillSolidRect(&rc, ref);

			if (lpDrawItemStruct->itemState & ODS_FOCUS)
				pDC.DrawFocusRect(&rc);

			if (id < gNumLayerColors)
			{
				HBRUSH hOldBrush = pDC.SelectBrush((HBRUSH)GetStockObject(NULL_BRUSH));
				pDC.Rectangle(rc.left+1, rc.top+1, rc.left+w+3, rc.top+h+3);
				pDC.SelectBrush(hOldBrush);

				CBrush brush;
				brush.CreateSolidBrush(gLayerColors[id].color);

				CRect	r(rc.left+2, rc.top+2, rc.left+2+w, rc.top+2+h);
				pDC.FillRect(&r, brush);
			}

			if (lpDrawItemStruct->itemState & ODS_SELECTED)
			{
				pDC.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
				pDC.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
			}
			else
			{
				pDC.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
				pDC.SetBkColor(::GetSysColor(COLOR_WINDOW));
			}

			pDC.TextOut(rc.left+((id < gNumLayerColors)? (w+6): 4), rc.top+2, (LPCTSTR)lpDrawItemStruct->itemData);
		}
	}
	
	return 0;
}