-1

Trying to change dimensions of my FMX form to emulate a 'FullScreen' mode, but using the Screen size backfires when a user has its settings with some bigger scaling, since the whole form becomes bigger than the screen.

How can I retrieve the scaling value so I can Size the form accordingly?

EDIT: That's a little snippet that shows what was my intention with the question and how it was solved. Thank you for you time and help.

 procedure TMyForm.ApplyFullScreen;
var
  tmpEscale: Extended;
begin
  BorderStyle := TFmxFormBorderStyle.None;
  Left := 0;
  Top := 0;

  tmpEscala := USER_DEFAULT_SCREEN_DPI / GetDeviceCaps(GetDC(0), LOGPIXELSX);

  Height := Round(Screen.Height * tmpEscala);
  Width := Round(Screen.Width * tmpEscala);
end;
TioGuedes
  • 43
  • 8
  • This is rather unclear. It would help if we knew exactly what your code was. Perhaps there is some simple mistake. – David Heffernan Aug 23 '17 at 20:24
  • The screen dimensions are reported differently depending on whether your app is DPI-aware or not (requiring virtualized values). Is your app DPI-aware? – Remy Lebeau Aug 23 '17 at 21:12
  • Sorry for the confusing question. GetDeviceCaps did it for me after I realized that the DPI info would change only after I have restarted my machine. @RemyLebeau my application was indeed DPI-aware, that was part of my confusion when setting dimmensions – TioGuedes Aug 24 '17 at 11:34

1 Answers1

0

When you call EnumDisplaySettings the resulting DEVMODE structure contains the DPI setting in the dmYResolution field. Beware that passing NULL as the device name to EnumDisplaySettings will get the information only for one screen, on a multimonitor system you should enumerate all the display devices.

You can also call GetDeviceCaps on a device context, and query for LOGPIXELSX and LOGPIXELSY.

The DPI corresponds to font scaling as follows:

  • 100% = 96 dpi
  • 125% = 120 dpi
  • 150% = 144 dpi
  • 200% = 192 dpi

For more information, it would be good to refer to the MSDN article on DPI-related APIs

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720