I'm working on a custom header control CMyHeaderCtrl
which is derived from the MFC class CHeaderCtrl
and overrides the DrawItem
method to do some custom drawing when the application is themed. At first I try to determine the theme font for header items, but it fails and GetThemeFont
returns the result 'element not found' (0x80070490)
.
The application which uses this control is linked against Common Controls 6. Here is some sample code:
void MyHeaderCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if(IsThemeActive() && IsAppThemed() && ComCtlVersionOK())
{
if(HTHEME hTheme = OpenThemeData(m_hWnd, L"HEADER"))
{
LOGFONTW lfw;
HRESULT hr = GetThemeFont(hTheme, lpDrawItemStruct->hDC, HP_HEADERITEM, HIS_NORMAL, TMT_CAPTIONFONT, &lfw);
ASSERT(hr == S_OK);
// ...
CloseThemeData(hTheme);
}
}
}
I also already tried other properties than TMT_CAPTIONFONT
like TMT_SMALLCAPTIONFONT
, TMT_BODYFONT
and so on. What could be wrong here?