Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Change colour of icon when drawing

Avatar of itdeptneci
itdeptneci asked on
DelphiSystem Programming
7 Comments1 Solution1047 ViewsLast Modified:
I want my owner drawn check box tick to be the same colour as the theme defined text colour. I currently draw an icon into the check box area. The icon is a black tick and its background gets changed quite happily by the theme.

I have tried drawing text in to the area and that's fine.

I guess I'll have to load the palette and change it somehow?
void CEUMBCheckBox::OnDrawCheckBoxEx (CDC *pDC, CRect rect, int nState, BOOL bHighlighted, BOOL bPressed, BOOL bEnabled)
{
	if (bHighlighted)
	{
		pDC->DrawFocusRect (rect);
	}
 
	rect.InflateRect (1, 1);
	// Is it enabled?
#if 0 // Trouble with colour themes with black background. The tick won't be visible because our Icon is black.
	pDC->FillSolidRect (&rect, bEnabled ? globalData.clrWindow :globalData.clrBarFace);
#else // This is better. Make sure the background is white and at least the tick is visible 
	pDC->FillSolidRect (&rect, bEnabled ? RGB(255,255,255) :globalData.clrBarFace);
#endif
 
	pDC->Draw3dRect (&rect,	globalData.clrBarDkShadow,	globalData.clrBarHilite);
	rect.DeflateRect (1, 1);
	pDC->Draw3dRect (&rect,	globalData.clrBarShadow,	globalData.clrBarLight);
	
	if (nState == 1)
	{
		//CMenuImages::Draw (pDC, CMenuImages::IdCheck, rect, CMenuImages::ImageBlack);
#if 0 // Use X text that supports colour themes
		rect.DeflateRect (1, 1);
		pDC->DrawText(_T("X"),rect,DT_CENTER|DT_TOP);
#else
		// Nice new tick Icon
		HICON hIcon = AfxGetApp()->LoadIcon(IDI_ICON_CHECK);
		DrawIconEx(pDC->m_hDC, rect.left, rect.top,hIcon,16,16,0, NULL, DI_NORMAL | DI_COMPAT);// | DI_DEFAULTSIZE);//rect.TopLeft(), hIcon);
#endif
	}
	else if (nState == 2)
	{
		rect.DeflateRect (1, 1);
		
		CBrush br;
		br.CreateHatchBrush (HS_DIAGCROSS, globalData.clrBtnText);
 
		pDC->FillRect (rect, &br);
	}
}
ASKER CERTIFIED SOLUTION
Avatar of alb66
alb66Flag of Italy image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answers