Sign in to follow this  
davidcoleman

MFC change control color - EnableThemeDialogTexture

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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;
}




Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this