From: Steve Achelis on
We're moving an MFC project from VS6 to VS2008. In the process we've
encountered a cosmetic bug wherein controls (statics, radios,
checkboxes, etc) that appear on a CTabCtrl within a dialog don't have
the same background color as the CTabCtrl. The CTabCtrl has a lighter
background than the dialog's background (which is okay) and the
controls' backgrounds (which isn't okay).

There are LOTS of posts about the background color of CTabCtrls on the
web (not necessary dealing with VS2008, but often with XP themes).
This page (written in 2004) http://www.codeproject.com/KB/wtl/ThemedDialog.aspx
shows the exact cosmetic problem we're experiencing and proposes a
solution. However, when I download and run the project (on Vista) it
has problems worse than the original cosmetic problem (i.e., all of
the controls have black backgrounds). The other posts I've seen show
people struggling with this, but without a clear solution.

Note that I'm not looking for fancy gradient dialogs, just to fix this
cosmetic problem (probably by setting the CTabCtrl's background to
match the dialog's background).

Any help is appreciated!

Thanks,

Steve
From: Seetharam on
I just ran the demo app in the codeproject article you mentioned and I
don't see any "black" controls.
Things look fine.
I tested on win7 - 32 bit with DWM on.

-Seetharam
From: Steve Achelis on
Really?! I just downloaded and rebuilt the project (ThemedDialogWin32)
and all controls are black, except for the edit control, the dot part
of the radio control, and the box part of the checkbox. I tried both
debug and release builds. Vista 64 bits (don't know what DWM is).
From: James Juno on
Perhaps look at

http://www.flounder.com/dialog_box_color.htm

Not sure how it will affect your tabs but you mention problems with other
controls. The codeproject sample in your link barely touches on overriding
OnCtlColor(), which Joe treats thoroughly.

-JJ

"Steve Achelis" <info(a)RescueRigger.com> wrote in message...
> We're moving an MFC project from VS6 to VS2008. In the process we've
> encountered a cosmetic bug wherein controls (statics, radios,
> checkboxes, etc) that appear on a CTabCtrl within a dialog don't have
> the same background color as the CTabCtrl. The CTabCtrl has a lighter
> background than the dialog's background (which is okay) and the
> controls' backgrounds (which isn't okay).
>
> There are LOTS of posts about the background color of CTabCtrls on the
> web (not necessary dealing with VS2008, but often with XP themes).
> This page (written in 2004)
> http://www.codeproject.com/KB/wtl/ThemedDialog.aspx
> shows the exact cosmetic problem we're experiencing and proposes a
> solution. However, when I download and run the project (on Vista) it
> has problems worse than the original cosmetic problem (i.e., all of
> the controls have black backgrounds). The other posts I've seen show
> people struggling with this, but without a clear solution.
>
> Note that I'm not looking for fancy gradient dialogs, just to fix this
> cosmetic problem (probably by setting the CTabCtrl's background to
> match the dialog's background).
>
> Any help is appreciated!
>
> Thanks,
>
> Steve

From: Steve Achelis on
I solved this by setting the CTabCtrl to Owner Draw and adding this
function to the dialog:

void CAddinBuilder::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT
lpDrawItemStruct)
{
CHAR szTabText[100];
INT bkColor;
Brush *cbr;
C_ITEM tci;

CTabCtrl *pTabCtrl = &m_oTabs; // My tab control.
ASSERT( pTabCtrl );

if (pTabCtrl->m_hWnd == lpDrawItemStruct->hwndItem)
{
cbr = &m_brushTab;
bkColor = RGB_WHITE;

memset(szTabText, '\0', sizeof(szTabText));

tci.mask = TCIF_TEXT;
tci.pszText = szTabText;
tci.cchTextMax = sizeof(szTabText)-1;

pTabCtrl->GetItem(lpDrawItemStruct->itemID, &tci);

CDC *dc = CDC::FromHandle(lpDrawItemStruct->hDC);

dc->FillRect(&lpDrawItemStruct->rcItem, cbr);
dc->SetBkColor(bkColor);

// The text isn't in the right place, so Imake this hacky adjustment.
lpDrawItemStruct->rcItem.left;
lpDrawItemStruct->rcItem.top;

TextOut(lpDrawItemStruct->hDC,
lpDrawItemStruct->rcItem.left,
lpDrawItemStruct->rcItem.top,
tci.pszText,
lstrlen(tci.pszText));
}