Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 16 AUG 2022 01:21:00PM Donald Bakke wrote:

We are trying to understand how to use the SCREENSIZE property correctly, especially when the scale setting is not 100%. We find that when our scaling is something else, like 125%, that the SCREENSIZE property does not return the coordinates we are expecting. Are we supposed to adjust the numbers returns from SCREENSIZE to account for scaling? We realize that this property is using the GetWindowRect API, but I think the average OI programmer would want results that could be used immediately, such as using them to place the location of another object.

Don Bakke

SRP Computer Solutions, Inc.


At 16 AUG 2022 02:22PM Carl Pates wrote:

Hi Don,

By default all sizing coordinates used in properties, methods and events are scaled relative to the monitor DPI that the parent form is on, and relative to any custom scaling factor. i.e. they represent a view as if everything were running at 96DPI - they are Device Independent Pixels or "DIPs" (this is basically what the "Scaled" Property trait means in the docs).

If you want coordinates in actual pixels, to use with other Windows API calls which generally are not DPI aware, then you can do one of two things:

1) Switch the SCALEUNITS property to Pixels before getting the SCREENSIZE (and reset it afterwards):

   call set_Property_Only( @window, "SCALEUNITS", PS_SCU_PIXELS$ )

   screenSize = get_Property( @window, "SCREENSIZE" )

   call set_Property_Only( @window, "SCALEUNITS", PS_SCU_DIPS$ ) 

2) Use the SCALESIZE method on the results of the returned SCREENSIZE property.

   screenSize = get_Property( @window, "SCREENSIZE" )

   screenSizePX = exec_Method( @window, "SCALESIZE", screenSize )

(FYI - Option (1) is always more accurate because because no scaling calculation is applied to the result, ergo there's less potential for integer rounding issues which can sometimes result in being a pixel different, which is sometimes the case in option (2) ).

Regards

Carl Pates

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/a2a1a0fcc0b8d7498f75cf5b0e044c2b.txt
  • Last modified: 2024/01/04 20:57
  • by 127.0.0.1