类型 TMessage 不是定义的 class 虚函数 C++ 生成器示例
type TMessage is not a defined class with virtual function C++ builder sample
我正在尝试使用 embarcadero 示例来使用 android 相机并收到错误消息:
"type TMessage is not a defined class with virtual function" on lines:
void __fastcall TForm1::DoMessageListener(const TObject *Sender, TMessage const *M) {
TMessageDidFinishTakingImageFromLibrary const *v = dynamic_cast<TMessageDidFinishTakingImageFromLibrary const *>(M);
if (v) {
Image1->Bitmap->Assign(v->Value);
}
}
在Delphi中,TMessage
works fine, but in C++Builder you must use TMessageBase
改为:
void __fastcall TForm1::DoMessageListener(const TObject *Sender, TMessageBase const *M)
这在文档中有明确说明:
Sending and Receiving Messages Using the RTL:
The RTL only defines one type of message, TMessage
. It is actually a template that you can use to create messages for specific types of values; for example: TMessage<int>
or TMessage<UnicodeString>
. You can also subclass TMessage
to define your own message types or, if you are using FireMonkey, you can reuse the message types defined by the framework.
Note: For C++ projects use TMessageBase
instead of TMessage
.
TMessage
represents the base class used for message purposes. It can be inherited in order to send custom messages.
Warning: For C++ projects, use TMessageBase
instead.
Alias to System.Messaging.TMessage
.
Use System.Messaging.TMessageBase
for C++ projects instead of System.Messaging.TMessage
.
文档的 System.Messaging (C++) 示例中也演示了 TMessageBase
的这种用法。
我正在尝试使用 embarcadero 示例来使用 android 相机并收到错误消息:
"type TMessage is not a defined class with virtual function" on lines:
void __fastcall TForm1::DoMessageListener(const TObject *Sender, TMessage const *M) {
TMessageDidFinishTakingImageFromLibrary const *v = dynamic_cast<TMessageDidFinishTakingImageFromLibrary const *>(M);
if (v) {
Image1->Bitmap->Assign(v->Value);
}
}
在Delphi中,TMessage
works fine, but in C++Builder you must use TMessageBase
改为:
void __fastcall TForm1::DoMessageListener(const TObject *Sender, TMessageBase const *M)
这在文档中有明确说明:
Sending and Receiving Messages Using the RTL:
The RTL only defines one type of message,
TMessage
. It is actually a template that you can use to create messages for specific types of values; for example:TMessage<int>
orTMessage<UnicodeString>
. You can also subclassTMessage
to define your own message types or, if you are using FireMonkey, you can reuse the message types defined by the framework.Note: For C++ projects use
TMessageBase
instead ofTMessage
.
TMessage
represents the base class used for message purposes. It can be inherited in order to send custom messages.Warning: For C++ projects, use
TMessageBase
instead.
Alias to
System.Messaging.TMessage
.Use
System.Messaging.TMessageBase
for C++ projects instead ofSystem.Messaging.TMessage
.
文档的 System.Messaging (C++) 示例中也演示了 TMessageBase
的这种用法。