[Module] DPI Awareness

Share your advanced PureBasic knowledge/code with the community.
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: [Module] DPI Awareness

Post by Rinzwind »

Just a note... it works as long as you do not move the Window to a monitor with different DPI settings.
dige
Addict
Addict
Posts: 1247
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: [Module] DPI Awareness

Post by dige »

Hello Thunder93, many thanks for the Per-Monitor DPI Awareness example.

Since the PB dpi aware supported is there a way acivate 'Per-Monitor DPI Awareness'
and use the PB commands?

Ciao Dige
"Daddy, I'll run faster, then it is not so far..."
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: [Module] DPI Awareness

Post by Rinzwind »

Just a note

As far as I could figure out by searching the internet, the DPI awareness constant values as needed for SetProcessDpiAwarenessContext are as follows:

Code: Select all

#DPI_AWARENESS_CONTEXT_UNAWARE = 16
#DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = 17
#DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = 18
#DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = 34

corrected by peeking with visual studio c++... and checking result in taskmgr after SetProcessDpiAwarenessContext_  (nowhere else to be found...) :
#DPI_AWARENESS_CONTEXT_UNAWARE = $6010 ;24592
#DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = $9011 ;36881
#DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = $12 ;18
#DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = $22 ;34
#DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = $40006010 ;1073766416
They're some wacky pointer anonymous structure stuff? MS...

Code: Select all

#define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name
DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
#define DPI_AWARENESS_CONTEXT_UNAWARE               ((DPI_AWARENESS_CONTEXT)-1)
#define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE          ((DPI_AWARENESS_CONTEXT)-2)
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE     ((DPI_AWARENESS_CONTEXT)-3)
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2  ((DPI_AWARENESS_CONTEXT)-4)
#define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED     ((DPI_AWARENESS_CONTEXT)-5)
Post Reply