// This function is called every time the button background needs to be painted.
// If the button is in transparent mode this function will NOT be called.
//
// Parameters:
//		[IN]	pDC
//				Pointer to a CDC object that indicates the device context.
//		[IN]	pRect
//				Pointer to a CRect object that indicates the bounds of the
//				area to be painted.
//
// Return value:
//		BTNST_OK
//			Function executed successfully.
//
DWORD CButtonST::OnDrawBackground(CDCHandle pDC, LPCRECT pRect)
{
	COLORREF	crColor;

	if (m_bMouseOnButton || m_bIsPressed)
		{
		crColor = m_crColors[BTNST_COLOR_BK_IN];
		}
	else
		{
		crColor = m_crColors[BTNST_COLOR_BK_OUT];
		}

	CBrush		brBackground;

	brBackground.CreateSolidBrush(crColor);
	pDC.FillRect(pRect, brBackground);

	return BTNST_OK;
} // End of OnDrawBackground
示例#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;
}
示例#3
0
LRESULT CLogListBox::OnDrawitem(UINT uMsg, WPARAM wParam, LPARAM lParam,BOOL& bHandled)
{
	LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam;
	if(!dis) return FALSE;
      
	LogListBoxItem * item = (LogListBoxItem *)dis->itemData;
	if(!item) return FALSE;
	
   CDCHandle dc = dis->hDC;

   if(dis->itemAction & (ODA_DRAWENTIRE|ODA_SELECT))
   {
		dc.SetBkColor(GetSysColor(COLOR_WINDOW));
		dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
      CRect r(dis->rcItem);
		if(!(dis->itemState & ODS_SELECTED ))
		{
			CBrush br;
			br.CreateSolidBrush(GetSysColor(COLOR_WINDOW));
			dc.FillRect(r,br);
		}
		CRect rct;
      GetClientRect(&rct);

		if(dis->itemState & ODS_SELECTED )
		{
			CRect rd(dis->rcItem);
			GuiTools::FillRectGradient(dis->hDC,rd,0xEAE2D9, 0xD3C1AF, false);
		}
		else if(dis->itemID != GetCount()-1) // If it isn't last item
		{
			CPen pen;
			pen.CreatePen(PS_SOLID, 1, RGB(190,190,190));
			SelectObject(dc.m_hDC, pen);
			dc.MoveTo(rct.left, r.bottom-1);
			dc.LineTo(rct.right, r.bottom-1);
		}
			  
		SetBkMode(dc.m_hDC,TRANSPARENT);

		SIZE TimeLabelDimensions;
		SelectObject(dc.m_hDC, NormalFont);
		GetTextExtentPoint32(dc, item->Time, item->Time.GetLength(), &TimeLabelDimensions);
		
		// Writing error time
		
		ExtTextOutW(dc.m_hDC, rct.right-5-TimeLabelDimensions.cx, r.top + LLB_VertMargin, ETO_CLIPPED, r, item->Time, item->Time.GetLength(), 0);
		// Writing error title
		SelectObject(dc.m_hDC, UnderlineFont);
		ExtTextOutW(dc.m_hDC, r.left+56, r.top + LLB_VertMargin, ETO_CLIPPED, r, item->strTitle, wcslen(item->strTitle), 0);
		
		// Writing some info
		SelectObject(dc.m_hDC, NormalFont);
		RECT ItemRect={r.left+56, r.top + LLB_VertMargin + LLB_VertDivider + item->TitleHeight, 
							r.right - 10, r.bottom-LLB_VertMargin};
		dc.DrawText(item->Info, item->Info.GetLength() , &ItemRect, DT_NOPREFIX);
			
		// Writing error text with bold (explication of error)
		SelectObject(dc.m_hDC, BoldFont);
		RECT TextRect = {r.left+56, LLB_VertMargin +r.top+ item->TitleHeight+LLB_VertDivider+((item->Info.GetLength())?(item->InfoHeight+LLB_VertDivider):0), r.right - 10, r.bottom-LLB_VertMargin};
		dc.DrawText(item->strText,  wcslen(item->strText), &TextRect, DT_NOPREFIX);

		if(item->Type == logError)
			dc.DrawIcon(12,r.top+8,ErrorIcon);
		else if(item->Type == logWarning)
			dc.DrawIcon(12,r.top+8,WarningIcon);
	}
  
	bHandled = true;
	return 0;
}