How to set a thread's DPI_AWARENESS_CONTEXT in a WPF application?

1.2k views Asked by At

I'm trying to figure out how I can temporarily disable DPI awareness in a WPF-application to set Window Placement. Following this example

I'm essentially trying to run the following from my Window's code behind:

DPI_AWARENESS_CONTEXT previousDpiContext = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
BOOL ret = SetWindowPlacement(hwnd, wp);
SetThreadDpiAwarenessContext(previousDpiContext);

But I can't figure out how this would work with interop. I have set up some basic Window Placement interop using the example here

0

There are 0 answers