【发布时间】:2016-04-22 08:40:43
【问题描述】:
美好的一天。我在 Embarcadero Xe8 中用 C++ Builder 编写。我在 Ios 和 android 上做移动应用程序项目并遇到这样的问题:我无法捕捉到手机锁屏事件。我以前总是这样做的:
bool TForm1::HandleApp(TApplicationEvent a, TObject *x)
{
if (a == TApplicationEvent::EnteredBackground)
{
MediaPlayer1->Stop();
}
return true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
_di_IFMXApplicationEventService a;
if (TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXApplicationEventService), &a))
{
a->SetApplicationEventHandler(TForm1::HandleApp);
}
}
但是一个错误:
\Unit1.cpp(33):无法初始化“TApplicationEventHandler”类型的参数(又名“bool (closure *)(Fmx::Platform::TApplicationEvent, System::TObject __borland_class *__strong) __attribute((pcs("aapcs-vfp")))') 左值类型为 'bool (__closure *)(Fmx::Platform::TApplicationEvent, System::TObject __borland_class *__strong)' FMX.Platform.hpp(252):在此处将参数传递给参数“AEventHandler”
我不知道还能做什么!你能帮帮我吗?
【问题讨论】:
-
附带说明,您不应该在 C++ 中使用
OnCreate事件。它是一个 Delphi 习语,可以在 C++ 中产生非法行为。改写类构造函数 (__fastcall TForm1(TComponent*))。
标签: android c++builder firemonkey c++builder-xe8