MFC change control color - EnableThemeDialogTexture

Started by
2 comments, last by davidcoleman 15 years, 3 months ago
I have changed main dialog's background color in OnEraseBkgnd to white but all my controls have still gray background. I tried setting their Transparent parameter to true but it makes no difference. I also changed manifest so program uses XP style. Any ideas? Thanks! [Edited by - davidcoleman on December 25, 2008 3:09:27 PM]
Advertisement
Hi,

Your dialog can handle the ON_WM_CTLCOLOR() message.

The message handler is OnCtlColor, see http://msdn.microsoft.com/en-us/library/0wwk06hc(VS.80).aspx

You'll want to do something like:

HBRUSH FooDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor){	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);	        //Get the ID of the window for which the message is being handled        int nID = pWnd->GetDlgCtrlID();        //check the control type	if (nCtlColor == CTLCOLOR_BTN )	{		if(nID==IDC_COLOREDBUTTON)		{			pDC->SetBkColor( RGB(255,255,255) );		}	}		return hbr;}
Hi
I tried it and also tried excluding both ifs to change back color of everything , but not all elements are affected... for example trackbars have still ugly background.
I am also trying to place them on tab control and make EnableThemeDialogTexture Function work, but without success. Any experience with that?
I did make EnableThemeDialogTexture function work. Now all controls have the color of the tabControl ... sort of...
Since XP styled Tab has gradient background, controls placed on top have still noticeable different color, but controls on bottom of the tab smoothly blend with tabcolor

I can not override ON_WM_CTLCOLOR since then if I make everything draw transparent I end up with their background color black

Any ideas?

This topic is closed to new replies.

Advertisement