Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WINDOWS Set DPI Awareness
#4
(05-08-2025, 08:32 PM)James D Jarvis Wrote: Thank you. I was just messing about with DPI-aware controls in a another programming package. 

This is more impressive in windowed mode. Now I can actually create a program that's the real screen width of my system (or closer to it), without having to mess with settings. Thanks again.

One thing to note -- you may want to set $SCREENHIDE at the start of your program, before you set the DPI Awareness.  The Windows documentation reads:

Quote:You must call this API before you call any APIs that depend on the DPI awareness (including before creating any UI in your process).

So technically you're supposed to call this before making any graphical windows and such, to prevent problems.  I'd suggest something like:
Code: (Select All)

$SCREENHIDE

Declare Dynamic Library "user32"
    Function DPI& Alias SetProcessDpiAwarenessContext (ByVal dpiContext As _Offset)
End Declare
Const UNAWARE = -1, AWARE = -2, PER_MONITOR_AWARE = -3
Const PER_MONITOR_AWARE_V2 = -4, UNAWARE_GDISCALED = -5

result = DPI(Aware)
_DELAY 0.2 'always nice for a slight delay in this type of thing to make certain windows has time to register changes.
_SCREENSHOW

SCREEN _NEWIMAGE(Wide, Tall, Mode)  <-- set as desired here

(OR similar.  I haven't actually tested the above, so just use it as an illustration of the program flow you'd want to set up.  If that doesn't work on the first try, look up the SCREENHIDE and SCREENSHOW examples on the wiki and sort out whatever quirk I may have missed in the proper syntax/usage.)

(05-08-2025, 08:39 PM)Jack Wrote: thank you Steve Smile 
how about a cross-platform solution  Big Grin

Wish I could, but I'm a windows user.  I know about squat about linux/mac, but I imagine they'd be quite a bit more difficult to sort out.  

Linux is definitely gonna be a cluster since there's both X and Wayland and they handle it differently.

I'll leave it to the other devs to sort those OSes out. Best I can do is offer this little tidbit for our windows' users. Wink
Reply


Messages In This Thread
WINDOWS Set DPI Awareness - by SMcNeill - 05-08-2025, 02:34 AM
RE: WINDOWS Set DPI Awareness - by James D Jarvis - 05-08-2025, 08:32 PM
RE: WINDOWS Set DPI Awareness - by SMcNeill - 05-08-2025, 08:44 PM
RE: WINDOWS Set DPI Awareness - by Jack - 05-08-2025, 08:39 PM
RE: WINDOWS Set DPI Awareness - by SMcNeill - 05-09-2025, 12:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Snapback Windows SMcNeill 3 1,320 10-11-2023, 05:32 PM
Last Post: SMcNeill
  Windows Magnifier SMcNeill 10 2,446 12-28-2022, 12:07 AM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)