dahall / Vanara

A set of .NET libraries for Windows implementing PInvoke calls to many native Windows APIs with supporting wrappers.
MIT License
1.75k stars 190 forks source link

DPI_AWARENESS_CONTEXT enum values missing #417

Closed shravan2x closed 1 year ago

shravan2x commented 1 year ago

I'm trying to set the DPI awareness of my application using this piece of code:

User32.SetProcessDpiAwarenessContext(new User32.DPI_AWARENESS_CONTEXT(User32.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE));

The issue is that the DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE enum value defined at https://learn.microsoft.com/en-us/windows/win32/hidpi/dpi-awareness-context doesn't seem to be a constant in the library. Are DPI_AWARENESS_CONTEXT enum values defined somewhere else?

I see one enum at User32.DPI_AWARENESS, but this is both out of date and the values are incorrect. For example, DPI_AWARENESS_SYSTEM_AWARE has a value of 1 when it should be -2.

dahall commented 1 year ago

I've added those constants to the DPI_AWARENEXT_CONTEXT struct. You can use them like follows:

User32.SetProcessDpiAwarenessContext(User32.DPI_AWARENESS_CONTEXT.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE);

You can pull this build from AppVeyor (see home page) or wait about a week for my next release.

shravan2x commented 1 year ago

Thanks for adding them!