Angus Robertson 710 Posted Thursday at 05:20 PM I design forms on a 4K monitor running at 120 dpi, but have a second side monitor that runs at 96 dpi, so no scaling. My forms all store their screen position and size. If I move a form onto the side monitor, close and re-open it, Form.PixelsPerInch seems to be that of the primary monitor, not the side monitor, so the form gets smaller in size, because the wrong scaling was saved. Is there a way to persuade Delphi to scale the form according to the monitor on which it is opened, rather than the primary monitor? Angus Share this post Link to post
David Heffernan 2514 Posted Thursday at 05:22 PM Just now, Angus Robertson said: Is there a way to persuade Delphi to scale the form according to the monitor on which it is opened, rather than the primary monitor? This is already how the RTL works. I imagine there's a logic error somewhere in your code. Maybe in the code that persists position/size. Or perhaps something else. Share this post Link to post
Angus Robertson 710 Posted Thursday at 06:20 PM I don't have any scaling or screen code, I just save HWTL. When opened on the 96dpi monitor, Screen.PixelsPerInch says 120 not 96, so I don't believe the correct monitor is being set when I change Width to move it to the other monitor. Or am I supposed to rescale the form myself at that point? Angus Share this post Link to post
David Heffernan 2514 Posted yesterday at 06:24 AM I can't understand what you are actually doing. Because you've described it rather imprecisely. Share this post Link to post
David Heffernan 2514 Posted yesterday at 06:59 AM But fwiw when i persist window location I also persist the dpi of the monitor where the window was located so that when it's time to restore size and position this can be done even if the window is on a different monitor or the dpi of the monitors has changed. Perhaps this is your issue. Perhaps not. With no detail all we can do is guess. It should be simple to make a trivial do nothing example to demonstrate. Share this post Link to post
dummzeuch 1763 Posted yesterday at 08:00 AM 13 hours ago, Angus Robertson said: I don't have any scaling or screen code, I just save HWTL. When opened on the 96dpi monitor, Screen.PixelsPerInch says 120 not 96, so I don't believe the correct monitor is being set when I change Width to move it to the other monitor. Or am I supposed to rescale the form myself at that point? I found the VCL's built in scaling lacking a lot on systems with monitors with different scale factors. My "solution" was to do the scaling myself, which turned into a nightmare, because it means fighting the VCL's built in code. Especially when the code that works perfectly in mixed scaling then falls flat on High DPI only settings, so I have to test in many different configurations which consumes time to no end. Sometimes I wish I had never bought a High DPI monitor. Life was much simpler back then. 😉 (Sorry to be unhelpful, I just wanted to tell you that you are not alone in experiencing these problems.) Share this post Link to post
Lars Fosdal 1987 Posted yesterday at 08:18 AM @Angus Robertson - Have you tried the various scaling approaches that can be set in the Manifest - such as Per Monitor V2 ? https://docwiki.embarcadero.com/RADStudio/Florence/en/Per_Monitor_V2 Share this post Link to post
Angus Robertson 710 Posted yesterday at 09:04 AM The program in question is an ICS sample, https://svn.overbyte.be/svn/icsv9/demos-delphi-extra/IcsAppMonMan1.pas It's a Websocket monitoring application. It saves the form position and size in the same way as 50 other ICS samples have for 25 years, nothing clever. But it does not work with Delphi 11 on the secondary monitor with a different DPI to the primary. Since the design DPI and monitor DPI are the same, there should be no scaling, that is the issue. But Delphi thinks it's on the wrong monitor. I'm not going to update 50 samples for this rare situation, but this particular ICS sample stays open on my side screen 24/7, only stopping for reboots, after which I have to resize it, annoyingly. Angus Share this post Link to post
Lars Fosdal 1987 Posted yesterday at 09:09 AM I can understand why you don't want to change all those apps - but did you try the settings to see if they have the desired effect? Share this post Link to post
David Heffernan 2514 Posted yesterday at 09:12 AM 1 hour ago, dummzeuch said: I found the VCL's built in scaling lacking a lot on systems with monitors with different scale factors. My "solution" was to do the scaling myself, which turned into a nightmare, because it means fighting the VCL's built in code. Especially when the code that works perfectly in mixed scaling then falls flat on High DPI only settings, so I have to test in many different configurations which consumes time to no end. As a counter-point to this, I'm using 11.3 and have been largely very satisfied with how the VCL handles per monitor and high DPI scaling. So I'm confident that it is possible to get this right. Share this post Link to post
Angus Robertson 710 Posted 22 hours ago Seems there are several form methods and properties I need to use to fix my problem, like ScaleForCurrentDPI, OnAfterMonitorDPIChanges, etc, so need to do a little more testing. Angus Share this post Link to post
Angus Robertson 710 Posted 20 hours ago Think I've fixed my scaling problem, by simply re-arranging the order in which the INI settings are read to change the form position and size. Setting Left causes a rescaling of the form if the monitor DPI changes, so if Width has been set for the new size before it scales, but if Width is set afterwards it does not change. Needed a lot of logging to see the order in which Delphi does the scaling. Angus 2 Share this post Link to post