0

我不是 C++ 专家,但需要将旧项目更新为 Embarcadero C++ Builder XE7。

此代码无法编译(fpFixed 行):

#include <System.UITypes.hpp>
...
NewText->Font->Pitch = fpFixed;

音高在哪里:

__property System::Uitypes::TFontPitch Pitch = {read=GetPitch, write=SetPitch, default=0};
void __fastcall SetPitch(const System::Uitypes::TFontPitch Value);

enum class DECLSPEC_DENUM TFontPitch : unsigned char { fpDefault, fpVariable, fpFixed };

错误:“E2451 未定义符号 'fpFixed'”

另外两次尝试:

NewText->Font->Pitch = TFontPitch.fpFixed;
NewText->Font->Pitch = System::Uitypes::TFontPitch.fpFixed;

两者都有错误:E2108 typedef 'TFontPitch' 使用不当

但这 - 奇怪的是 - 编译,没有警告:

System::Uitypes::TFontPitch( fpFixed );   // yes,no assignments here just an unused value
NewText->Font->Pitch = fpFixed;

这是什么解释,我在这里做错了吗?刚刚通过反复试验得出了这个“解决方案”。

4

1 回答 1

0

NewText->Font->Pitch = TFontPitch.fpFixed;
NewText->Font->Pitch = System::Uitypes::TFontPitch.fpFixed;

你在正确的轨道上,但你使用了错误的语法。使用::代替.

NewText->Font->Pitch = TFontPitch::fpFixed;
NewText->Font->Pitch = System::Uitypes::TFontPitch::fpFixed;

这记录在 Embarcadero 的 DocWiki 中:

强类型枚举 (C++0x)

于 2015-05-11T15:11:59.833 回答