TThemeServices :: DrawText未解决的链接错误

时间:2011-06-01 17:05:58

标签: c++builder vcl

我正在创建一个自定义组件(派生自TCustomCategoryPanelGroup)并执行一些自定义绘制操作。我想在启用主题时进行处理并适当地绘制文本。

以下是我在绘图函数中使用的一些代码片段:

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
}

当我尝试构建它时,我收到错误:

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

正如您所看到的,它正在寻找DrawTextA。我查看了Themes.hpp标题,并且只定义了ThemeServices::DrawText函数。

我不确定这里发生了什么。我想也许我错过了一个导入库,但我使用的所有其他ThemeServices函数都没有出现链接错误。

任何人都知道这里发生了什么?

1 个答案:

答案 0 :(得分:2)

我猜你有#include一些标题(windows.h?)包含类似这样的内容

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

您可以在文件中放置#undef DrawText来解决此问题。 (另见Conflict with DrawText function。)