7

I thought scaling an application in FireMonkey should be easy as it is supposed to work an a Retina-Mac too. It seems there is some background magic which chooses another style than, but this doesn't seem to be the case in Windows.

In VCL there was TForm.Scaled which does the job (more or less).

For FireMonkey I found this Article by Embarcadero but it seems Embarcadero is not quite sure if this approach is useful as in XE5 the sampleproject "ControlsDemo" doesn't contain the scale-trackbar anymore. It also requires to have a root-TLayout present in all forms for which the scale factor can be set. I don't have such a element in my forms (and I'm afraid to add one as I cannot be sure if I run in another firemonkey bug than).

So how do I account for different DPI-Settings using FireMonkey?

Edit: I tried hacking TPlatFormWin and set CurrentScreenScale to 2 but it didn't work: I got black toolbars, but no scaling, but at least it used the HighRes alternative from the provided TImage.MultiResBitmap.

Steffen Binas
  • 1,463
  • 20
  • 30
  • So do you have a high dpi monitor or are you trying to simulate on a regular 96 dpi display? – Warren P Jan 08 '14 at 13:07
  • 1
    Both ;-) I have a HighDPI Windows Tablet and simulate on the PC via font settings. – Steffen Binas Jan 08 '14 at 13:12
  • 2
    Alas, but the vector-based styles referred to in that article were replaced by bitmap-based ones in XE3 (or more exactly: the 'platform' styles are now bitmap based). As such, 'retina' displays are now supported by including *two* sets of Mac bitmap styles rather than any intrinsic resolution independence of the style format itself. That said, if you're OK with a custom style, have you tried one of the custom styles shipped with the product? Most are still vector based IIRC. – Chris Rolliston Jan 08 '14 at 13:22
  • @ChrisRolliston How can a style solve this? My TToolBar has a Height of e.g. 57 (saved in the fmx files). For HighDPI this value must grow. I think it would be very much work to make extra styles for HighDPI (think of different styles used on different Windows-Versions). But I'll follow the hint and check the styles out. – Steffen Binas Jan 08 '14 at 13:38
  • @Stebi - I meant using one of the provided custom styles (they're under the redist folder) – Chris Rolliston Jan 08 '14 at 17:19
  • @ChrisRolliston, Shouldn't that be an answer? – Johan Jul 26 '14 at 12:53

2 Answers2

0

If anyone reads this... my experience with Windows desktop Firemonkey is that you have to take care of OS DPI setting manually and it's OK to put your controls in a top container (a TLayout) that's Scale is set according to the OS screen DPI settings (determined with some low level code). However there are cases when you need to reverse this scaling - for example a Viewport3D must be scaled back 1/X to correctly show inside the scaled up container. Otherwise pixel level artifacts will show, image quality will be awful. This scale up/scale back technique works nicely.

kgz
  • 527
  • 2
  • 10
-2

U can do something like this to change the root TLayout:

with 100 being the default

if windowsscale>0 then begin
  LayoutScale.height:=ClientHeight*100/windowsscale;
  LayoutScale.Width :=Clientwidth*100/windowsscale;
  LayoutScale.Scale.X:=windowsscale/100;
  LayoutScale.Scale.Y:=windowsscale/100;
end;
r_j
  • 1,348
  • 15
  • 35