0

I have a WPF application hosting winforms controls. When I run the application in Windows 8.1. The Ui is cluttered. As a work around I am changing the system DPi and resolution settings. How ever what I want is to make the application's dpiaware as false. From my research I know that I can use the manifest or use an api setdpiawareness from shcore.dll(win8.1). The manifest is more suitable to me. I have checked Disable DPI awareness for WPF application .

My query is more with respect to manifest , I am writing a sample application to make dpiaware as false. I have already embed the manifest, below is what it looks like.

 <asmv3:application>
  <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
    <dpiAware>false</dpiAware>
  </asmv3:windowsSettings>
</asmv3:application>

I am trying to run the below and every time the value of Dpiaware is true. Any thing that I am doing wrong in the manifest? or any alternatives?

[DllImport("user32.dll", SetLastError = true)]
static extern bool IsProcessDPIAware();
protected override void OnStartup(StartupEventArgs e)
{
    Process_DPI_Awareness p;
    p = 0;
    base.OnStartup(e);

    bool h = IsProcessDPIAware();
    if(h)
        MessageBox.Show("Dpi is 1");
    else
        MessageBox.Show("Dpi is not true");
}
Community
  • 1
  • 1
  • 1
    Use the [[DisableDpiAwareness](https://msdn.microsoft.com/en-us/library/system.windows.media.disabledpiawarenessattribute%28v=vs.110%29.aspx)] attribute. – Hans Passant Feb 15 '15 at 13:01
  • I had initial hiccups getting through the design. But essentially after having the right design in place this attribute worked splendidly! – Theodore Cartman Feb 25 '15 at 09:03

1 Answers1

0

Like Passant mentioned DisableDpiAwareness works greatly!