Author Topic: Determine if screen size fonts/text/apps/etc is set above 100%  (Read 70 times)

JTaylor

  • Pundit
  • *****
  • Posts: 1831
    • Data & Stuff Inc.
How can I determine if screen size for fonts/text/apps/etc is set above 100%?   Not finding the right words to search for I assume.

Thanks.

Jim

td

  • Tech Support
  • *****
  • Posts: 4083
    • WinBatch
Re: Determine if screen size fonts/text/apps/etc is set above 100%
« Reply #1 on: July 26, 2022, 09:48:41 pm »
There may be easier ways to accomplish it but this is the first one that comes to mind. To get the logical pixels, you can use the Win32 function GetDeviceCaps with the LOGPIXELSX in the index parameter. You will first need to get a DC handle to use as the first parameter to the function. Logical pixels provided by LOGPIXELSX are the logical pixels per inch in the horizontal direction.

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

  • Pundit
  • *****
  • Posts: 1831
    • Data & Stuff Inc.
Re: Determine if screen size fonts/text/apps/etc is set above 100%
« Reply #2 on: July 27, 2022, 06:20:23 am »
Thanks.   Surprised this isn't part of WinMetrics() or SysParamInfo().   Seems like something many people would want to know.   Although, I guess this is the first time it has come up for me in over 25 years using WinBatch so maybe not :)

Jim

td

  • Tech Support
  • *****
  • Posts: 4083
    • WinBatch
Re: Determine if screen size fonts/text/apps/etc is set above 100%
« Reply #3 on: July 27, 2022, 11:11:16 am »
Hate to see you tire out your fingers so in case you haven't already done it, here is a quick and dirty example that may speed things a bit.

Code: Winbatch
;; Note: If WinBatch was not manifested to be DPI aware
;; this would not work.  But it is so it does.

hDC = DllCall("User32.dll", long_ptr:"GetDC", lpnull)

LOGPIXELSX = 88
nPixPerInchX = DllCall("Gdi32.dll", long:"GetDeviceCaps", long:hDC, long:LOGPIXELSX)

;; 96 is the default Windows scaling.
nScallingPercent = (nPixPerInchX/96.0) * 100

x =  DllCall("User32.dll", long:"ReleaseDC", lpnull, long:hDC)

Message("Desktop Scalling",  nScallingPercent:"%%")

;; This would require Windows 10 - 1604 or later
;;nPixPerInchX10 = DllCall("User32.dll", long:"GetDpiForWindow", long:DllHwnd(""))

exit
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

  • Pundit
  • *****
  • Posts: 1831
    • Data & Stuff Inc.
Re: Determine if screen size fonts/text/apps/etc is set above 100%
« Reply #4 on: July 27, 2022, 12:00:28 pm »
I should have responded earlier so as to save you the time.  I did get it working.  I added it as a function to my Extender just in case I needed it for other things.    I was going to ask though.   Is 96 always the base?   I made that assumption in solving the problem and I see you used it as well.

Thanks.   I appreciate the code.   Always good for comparison.

Jim

td

  • Tech Support
  • *****
  • Posts: 4083
    • WinBatch
Re: Determine if screen size fonts/text/apps/etc is set above 100%
« Reply #5 on: July 27, 2022, 12:13:39 pm »
Yes, 96 logical pixels per inch is always considered 100% scaling.

As far as wasting time goes. Spending a few minutes writing that script turned out not to be a waste of time at all.  Happened to find a bug in the DllCall function (not demonstrated by the example as presented.)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

  • Pundit
  • *****
  • Posts: 1831
    • Data & Stuff Inc.
Re: Determine if screen size fonts/text/apps/etc is set above 100%
« Reply #6 on: July 27, 2022, 12:53:17 pm »
Excellent.  Thanks again.



Jim