Re: Background color on a tab page with XP theme
On Tue, 24 Jun 2008 17:05:39 -0600, "Timothy Dean" <my_email@this.com>
wrote:
I am already calling EnableThemeDialogTexture. I don't have an application
that I know uses a tab control (not property sheet / pages) that looks
right. If you use the propery sheet / property page approach, I think it
works fine. Are you sure your example is displaying the gradiant properly
and not just pure white?
I am certain.
If you size your dialog pages to fill the tab
control, it may appear to be correct, but in fact is flat white with no
gradient. When your dialog pages are sized smaller than the tab control, it
becomes more obvious.
No, the gradient is present, and it is identical to property sheet
implementations such as used by control panel applets. FWIW, here is my tab
control's page creation function:
void
SubDialogTabCtrl::CreatePageWindow(
SubDialogPage& page,
bool sizeToFitTabCtrl)
{
if (!page.m_hWnd)
{
if (!page.CreateGUI(*this, CRect(0, 0, 100, 100)))
AfxThrowResourceException();
if (sizeToFitTabCtrl)
{
WndEx::ClientRect rc(*this);
AdjustRect(false, rc);
page.MoveWindow(rc);
}
}
}
The page CreateGUI function is:
bool
SubDialog::CreateGUI(CWnd& parent, const CRect& rc)
{
// The "base" typedef is for CDialog.
return base::Create(GetActualID(), &parent);
}
The page OnInitDialog handler is:
BOOL SubDialogPage::OnInitDialog()
{
// The "base" typedef is for SubDialog.
base::OnInitDialog();
if (UserEx::IsAppThemed())
EnableThemeDialogTexture(m_hWnd, ETDT_ENABLETAB);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Finally, the UserEx::IsAppThemed function is:
bool
UserEx::IsAppThemed()
{
return OsVersion::AtLeastXP() && ::IsAppThemed();
}
Maybe you could try calling ::IsAppThemed() and see what it returns. If it
returns false, then I'd guess your (unconditional) EnableThemeDialogTexture
would have no effect. Or, maybe you're delay-loading uxtheme.dll, and it's
failing, and you're eating the exception it throws. What does
EnableThemeDialogTexture return?
I tried adding the styles you mentioned but it still
looks the same. I have seen other people who have asked this question out
on the net, but so far, no solutions other than using property sheet /
pages.
I don't know what else to tell you. I don't appear to be doing anything
unusual, and I have no recollection of this ever not working.
--
Doug Harrison
Visual C++ MVP