SHCore SetProcessDpiAwareness vs user32 SetProcessDpiAwarenessContext

Hi!

We’ve had a Wotja app update rejected by the Microsoft Store earlier today:

Warning: The DPI-awareness validation test detected following Warnings:
File ***.exe neither has PerMonitorV2 manifested in the manifest nor calls into DPI Awareness APIs for ex: user32!SetProcessDpiAwarenessContext or user32!SetThreadDpiAwarenessContext.

This is quite annoying, as of course Juce does call DPI Awareness APIs, but through SetProcessDpiAwareness … (in SHCore.dll).

The rejection happened very quickly; I suspect they’ve added an automated check, and the check doesn’t cover all routes to DPI Awareness checking. :frowning:

Is Juce going to be changed to call SetProcessDpiAwarenessContext in user32 to deal with this…?

Thanks, and best wishes to all,

Pete

Just to note… I found this: https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/using-the-xaml-hosting-api

If you don’t already have an assembly manifest in your project, add a new XML file to your project and name it app.manifest.
In your assembly manifest, include the compatibility element and the child elements shown in the following example. Replace the Id attribute of the maxVersionTested element with the version number of Windows 10 you are targeting (this must be Windows 10, version 1903 or a later release).

So, I took their example and added a dpiAwareness section inside WindowsSettings … see https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/mt846517(v%3Dvs.85)

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
        <application>
            <!-- Windows 10 -->
            <maxversiontested Id="10.0.18362.0"/>
            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
            <windowsSettings>
              <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
              <dpiAware>true</dpiAware>
          </windowsSettings>
        </application>
    </compatibility>
</assembly>

I hope this alternative approach works :slight_smile:

Pete

… and it is still rejected! :frowning:

Did you get anywhere on this?

I have been fighting this all day. Ive tried everything i can think of.

I opened a ticket with microsoft.

Im thinking its a bug with them.
I just did a release last week and it was fine, today, this…

I just heard back on my microsoft ticket. looks like it is a microsoft problem, they responded with this:

“Thank you for reporting this. We are looking into it. We will get back to you when we know more.”

Which means its something on their end.

FYI: I am not a JUCE user, my program is not related, its in Visual Studio/ c#. I just found this thread when googling for the problem.

1 Like

Hi! Very interesting to hear from you.

We have two apps variants, basically a Pro version and a Free version, built with the same code base.

Bizarrely, one of them passed certification, and the other one didn’t!

Microsoft are currently passing me around, I’ve yet to get traction with their developer support for this issue.

With best wishes,

Pete

apparently, i am limited to 3 replies per topic.

if bounced out again. im going to try putting the high DPI stuff back in.

I think they fixed it.

I submitted my app this morning and its been in certification for over 2 hours, yesterday it was bouncing out after a few minutes.

might want to give yours a try

–Karl

Thanks for the tip Karl - I’ll try it again now! :slight_smile: Pete

It didn’t work - same reason. Oh well! Pete

Many thanks to Karl @iddgroup or his suggestions, which led to the following solution, which did work!

Changes shown are to juce_win32_Windowing.cpp

Pete

...
// MPC BEGIN!
typedef BOOL(WINAPI* SetProcessDpiAwarenessContextFunc) (DPI_AWARENESS_CONTEXT);
static SetProcessDpiAwarenessContextFunc setProcessDpiAwarenessContext = nullptr;
// MPC END!

//==============================================================================
static void setDPIAwareness()
{
    // MPC BEGIN!
    if (setProcessDpiAwarenessContext  == nullptr) {
      HMODULE user32Module = GetModuleHandleA("User32.dll");
      // This is not available in all Windows 10 SDKs...
      setProcessDpiAwarenessContext = (SetProcessDpiAwarenessContextFunc)GetProcAddress(user32Module, "SetProcessDpiAwarenessContext");
      if (setProcessDpiAwarenessContext != nullptr) {
        setProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
      }
    }
    // MPC END!

   #if ! JUCE_DISABLE_WIN32_DPI_AWARENESS
    if (JUCEApplicationBase::isStandaloneApp())
    {
...

@jules I’d suggest the team add this to the code base, it might well help others … Pete

Your Welcome!

I did open a ticket with microsoft, it is clearly an issue on their end.

They did say there was something going on, but its not happening with everyone.

–Karl

Thanks again Karl!

I complained after being sent pillar to post by them, and was then told that they’re investigating - but have heard nothing else.

Anyhow the workaround seems fine, so onwards and upwards!

Pete

Had a response from Microsoft - “There was an issue with the WACK test that should be resolved now. Sorry for the inconvenience.”. Better late than never :slight_smile: Pete

1 Like

Thanks!

yes, I just resubmitted my original source and it was approved.

Cool :slight_smile: