Size Of GUI In Design Mode VS Reality

Old Topics related to the original "AutoGUI" ahk script editor.
SOTE
Posts: 1430
Joined: 15 Jun 2015, 06:21

Size Of GUI In Design Mode VS Reality

Post by SOTE » 18 Oct 2018, 07:49

There seems to be a significant size discrepancy between how the size of a GUI looks when in Design Mode versus when you save it and run it as a .AHK file. The Design Mode GUI appears much smaller, so then then creates the issue of building GUI that look too big or not quite what was intended. You can can do a visual comparison between the Design Mode GUIs and the GUIs as a .AHK file to see the difference.

I'm wondering if the cause of the GUI size difference issue is the version of Windows, screen resolution, or some other cause?
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Size Of GUI In Design Mode VS Reality

Post by TheDewd » 18 Oct 2018, 07:56

It may be possible that AutoGUI is using -DPIScale in its Gui options.

If you set your DPI to 100% does this fix the issue? If yes, then it's related to DPIScale.

Code: Select all

DPIScale [v1.1.11+]: Use Gui -DPIScale to disable DPI scaling, which is enabled by default. If DPI scaling is enabled on a system with a non-standard DPI setting, the Gui commands automatically scale coordinates and sizes to give controls roughly the same apparent size (but higher resolution). For example, with a DPI of 144 (150%), Gui Show, w100 would make the Gui 150 pixels wide, but A_GuiWidth would still return 100. A_ScreenDPI contains the system's current DPI.

DPI scaling only applies to Gui commands, so coordinates coming directly from other sources such as ControlGetPos or WinGetPos will not work. There are a number of ways to deal with this:
•Avoid using hard-coded coordinates wherever possible. For example, use the xp, xs, xm and x+m options for positioning controls and specify height in rows of text instead of pixels.
•Enable (Gui +DPIScale) and disable (Gui -DPIScale) scaling on the fly, as needed. Changing the setting does not affect positions or sizes which have already been set.
•Manually scale the coordinates. For example, x*(A_ScreenDPI/96) converts x from logical/Gui coordinates to physical/non-Gui coordinates.
SOTE
Posts: 1430
Joined: 15 Jun 2015, 06:21

Re: Size Of GUI In Design Mode VS Reality

Post by SOTE » 18 Oct 2018, 17:43

TheDewd wrote:
18 Oct 2018, 07:56
It may be possible that AutoGUI is using -DPIScale in its Gui options.

If you set your DPI to 100% does this fix the issue? If yes, then it's related to DPIScale.

Code: Select all

DPIScale [v1.1.11+]: Use Gui -DPIScale to disable DPI scaling, which is enabled by default. If DPI scaling is enabled on a system with a non-standard DPI setting, the Gui commands automatically scale coordinates and sizes to give controls roughly the same apparent size (but higher resolution). For example, with a DPI of 144 (150%), Gui Show, w100 would make the Gui 150 pixels wide, but A_GuiWidth would still return 100. A_ScreenDPI contains the system's current DPI.

DPI scaling only applies to Gui commands, so coordinates coming directly from other sources such as ControlGetPos or WinGetPos will not work. There are a number of ways to deal with this:
•Avoid using hard-coded coordinates wherever possible. For example, use the xp, xs, xm and x+m options for positioning controls and specify height in rows of text instead of pixels.
•Enable (Gui +DPIScale) and disable (Gui -DPIScale) scaling on the fly, as needed. Changing the setting does not affect positions or sizes which have already been set.
•Manually scale the coordinates. For example, x*(A_ScreenDPI/96) converts x from logical/Gui coordinates to physical/non-Gui coordinates.
Edit- Problem more precisely identified.

You appear correct that the DPIScale is part of the problem, however the "No DPI Scale" setting, from "Control" > "Properties" looks like it needs to be selected by default prior to building the GUI or using the clone tool, to not cause problems.

Note- You must first select "Design Mode", before you will see the menu option of "Control", and then "Properties". So it's also a situation where it can be easy for people to miss it or not be aware of it.

As for the size problem, when you are in "Design Mode", it appears to give a -DPIScale view, but then AutoGUI saves the GUI in a +DPIScale manner. You can't make changes to the GUI, as then you are forced to switch over to "Edit Mode". However, the damage appears already done with incorrect or unwanted X, Y, H, and W settings. If you add the GUI -DPIScale command to the GUI that you are making, after saving the GUI or in "Edit Mode", it could become a mess. This is because the controls can be all the wrong sizes in comparison to the window.

This is a pic of where people might want to change the DPI Scale prior or during building or editing the GUI in Design Mode. If you make the change, you want to do it before saving the GUI and while still in "Design Mode". Changing to or adding -DPIScale after saving the GUI to .ahk, can cause a mess of controls that are not in proportion.

Image
Post Reply

Return to “Old Topics”