[SOLVED] Wrong cursor position when scaling is not at 100% in windows display settings

Is this bug already reported? I couldn’t find it with a quick search…

So the bug occurs in windows dx. I didn’t test with opengl. When I set scaling to 100% everything works fine. When set to 125% for example, I get wrong cursor position when using the Mouse.GetState method.

Here is a screenshot showing which settings I am talking about:

Do you have a manifest in your project to make your app dpi aware? It’s added in the template projects.

I remember asking this before… I forgot the solution. Now it works :slight_smile:

Solution:
1.Either create a new MonoGame project and copy the app.manifest file from there to the project which does not have the app.manifest or just create a text file with this content and rename it to app.manifest:

<?xml version="1.0" encoding="utf-8"?>

    <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  
  
      <assemblyIdentity version="1.0.0.0" name="$safeprojectname$"/>
  
  
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  
  
        <security>
  
  
          <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
  
  
            <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
  
  
          </requestedPrivileges>
  
  
        </security>
  
  
      </trustInfo>
  
  
    

  
  
      <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
  
  
        <application>
  
  
          <!-- A list of the Windows versions that this application has been tested on and is
  
  
               is designed to work with. Uncomment the appropriate elements and Windows will 
  
  
               automatically selected the most compatible environment. -->
  
  
    

  
  
          <!-- Windows Vista -->
  
  
          <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
  
  
    

  
  
          <!-- Windows 7 -->
  
  
          <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
  
  
    

  
  
          <!-- Windows 8 -->
  
  
          <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
  
  
    

  
  
          <!-- Windows 8.1 -->
  
  
          <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
  
  
    

  
  
          <!-- Windows 10 -->
  
  
          <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
  
  
    

  
  
        </application>
  
  
      </compatibility>
  
  
    

  
  
      <application xmlns="urn:schemas-microsoft-com:asm.v3">
  
  
        <windowsSettings>
  
  
          <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
  
  
        </windowsSettings>
  
  
      </application>
  
  
    

  
  
    </assembly>

2.Add the app.manifest to the project in Visual Studio.
3.Right click the project and select properties. You should see the application properties where you should be able to select the app.manifest from a drop down menu.

2 Likes