Scott Saad
Scott Saad

Reputation: 18372

TThemeServices::DrawText unresolved link error

I'm creating a custom component (derived from TCustomCategoryPanelGroup) and performing some custom draw operations. I want to handle when Themes are enabled and draw text appropriately.

Here is a snippet of some code I have in a draw function:

int theBaseDrawFlags = DT_EXPANDTABS | DT_SINGLELINE | DT_VCENTER | DT_LEFT;
theBaseDrawFlags = DrawTextBiDiModeFlags( theBaseDrawFlags );

if ( TCustomCategoryPanelGroup::hsThemed == PanelGroup->HeaderStyle && ThemeServices()->ThemesEnabled )
{
    ThemeServices()->DrawText( ACanvas->Handle, ThemeServices()->GetElementDetails( tebNormalGroupHead ), m_CaptionTopLeft, m_TextRect, theBaseDrawFlags, 0 );
}
else
{
    // Draw without themes
}

When I attempt to build this I receive the error:

Unresolved external __fastcall Themes::TThemeServices::DrawTextA(HDC__ *, Themes::TThemedElementDetails&, const System::WideString, Types::TRect&, unsigned int, unsigned int)' referenced from  ....

As you can see it's looking for DrawTextA. I've looked at the Themes.hpp header and there is only a ThemeServices::DrawText function defined.

I'm not sure what's going on here. I thought perhaps that I was missing an import library, but all of the other ThemeServices functions that I use don't get link errors.

Anyone know what's going on here?

Upvotes: 1

Views: 667

Answers (1)

Uli Gerhardt
Uli Gerhardt

Reputation: 14001

I guess you have #included some header (windows.h?) that contains something like this

#ifdef UNICODE
#define DrawText DrawTextW
#else
#define DrawText DrawTextA
#endif

You can probably put an #undef DrawText in your file to work around this. (See also Conflict with DrawText function.)

Upvotes: 2

Related Questions