我需要获取正在显示我的应用程序的监视器的屏幕比例。多平台运行时TPlatFormServices
具有称为IFMXScreenService
的服务,该服务返回屏幕比例(GetScreenScale
)。
问题是它仅将其返回给主监视器。无论我的应用程序正在运行的哪个监视器,我都需要获取它。
下面是我的C ++代码,用于获取IFMXScreenService
。如何修改它以获得活动监视器的屏幕服务?
if (TPlatformServices::Current->SupportsPlatformService(__uuidof(IFMXScreenService)) == true)
{
pScreenService_ = TPlatformServices::Current->GetPlatformService(__uuidof(IFMXScreenService));
}
double TFormBase::GetScaleFactor(void)
{
double fScale = 0.0;
#ifdef WIN32
TPoint objTopLeft = TPoint(Left,Top);
HMONITOR hMonitor = MonitorFromPoint(objTopLeft,MONITOR_DEFAULTTONULL);
if (hMonitor != NULL)
{
DEVICE_SCALE_FACTOR nScaleFactor;
if (GetScaleFactorForMonitor(hMonitor,&nScaleFactor) == S_OK)
{
fScale = static_cast<double> ((static_cast<int> (nScaleFactor))) / 100.0;
}
}
if (fScale == 0.0)
{
fScale = ScreenService->ScreenScale;
}
#else
fScale = ScreenService->ScreenScale;
#endif
return fScale;
}
谢谢,
Aggie85