How to get screen resolution in Firemonkey XE3?
Asked Answered
B

1

5

How can I get the screen resolution in Firemonkey 2 (Delphi XE3)?

Bollay answered 9/10, 2012 at 17:9 Comment(0)
A
9

It's all changed in XE3. The platform support has been completely overhauled. See Pawel Glowacki's article for more.

var
  ScreenSvc: IFMXScreenService;
  Size: TPointF;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, IInterface(ScreenSvc)) then
  begin
    Size := ScreenSvc.GetScreenSize;
    ....
  end;
end;

In spite of the overhaul, this is still not much use if you have multiple monitors. Perhaps there is some multimon support in FMX2, but it's clearly not available in IFMXScreenService.

Aimeeaimil answered 9/10, 2012 at 17:14 Comment(9)
In XE3 Platform has not GetScreenSize method.Bollay
It's in FMX.PlatForm.IFMXScreenService.False
Sorry, I was looking at XE2 docs clearly. Update now corrects that.Aimeeaimil
Oh, thanks, it's working. And can i get screen height (width) without Start-panel in Windows?Bollay
@Bollay Not so far as I know. However, you can use the new registry based platform services to register your own plugin that will report that. You'd have to write conditional code for Windows and Mac and any other targets. But that would allow you to have high level code that did not need to know about the platform variations. Call Platform.TPlatformServices.AddPlatformService to register a new service.Aimeeaimil
i wonder how this would work on multi-monitor configuration. Those spoiled Apple fans, they love those hi-quality TVs :-)Dziggetai
@Arioch'The The only way to find out is to read the code. The docs don't say. Which is pretty lame in my view. Compare that to MSDN.Aimeeaimil
MSDN is mainly documenting long-established code. The one that even got mostly reproduced by WinE/Odin/ReactOS. FMX is developing in progress with major refactoring taking place "on air"...Dziggetai
@Arioch'The The Delphi documentation is also mainly documenting long-established code. MSDN documentation for WinRT existed before that product was launched. It was developed in tandem with the product. FMX documentation is years behind.Aimeeaimil

© 2022 - 2024 — McMap. All rights reserved.