再会。我在 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(闭包 *)(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'在这里
我不知道还能做什么!请你帮助我好吗?