0

I'm facing a issue which related to dpi setting of windows. If the windows dpi setting is set to 100% everything is fine. But if user changed it to 125%...some part of my application displayed a wrong size. I know the problem and I know how to deal with but my customer wants that when application running, if the current dpi setting of windows is not equal to 100% -> change it to 100%

And I'm standing still with the solution. Do you have some solution to change windows dpi setting value?

Thanks in advanced!!!

Bac Clunky
  • 353
  • 3
  • 6
  • 18
  • I would suggest fixing whatever problems you have with your application, or let the user know your app won't work as expected with their settings. Don't adjust the users computer – Sayse May 27 '14 at 09:43
  • put your UI elements in ViewBox so it will adjust screen automatically. – Dhaval Patel May 27 '14 at 09:45
  • the problem is the user computers are customer computers as well. They put a new request that they want to make a windows dpi setting must be always 100%...when application running – Bac Clunky May 27 '14 at 09:47
  • I wouldn't use an application which wants me to change my system settings to work. – Herm May 27 '14 at 09:47
  • @DhavalPatel but the customer wants to change a windows dpi setting value to 100% when application starts – Bac Clunky May 27 '14 at 09:49
  • @Herm you know, this is an special computer seems to run my application as a main application. So customer they want it to be changed by their request – Bac Clunky May 27 '14 at 09:50
  • @BacClunky:tell him that your application will resize as per resoultion it's not your task to set dpi 100 through your application.if user wants then he can change it. – Dhaval Patel May 27 '14 at 09:51
  • @DhavalPatel they pay money man :D – Bac Clunky May 27 '14 at 09:52

2 Answers2

2

You can do this by modifying the registry value of the registry key HKEY_CURRENT_USER\Control Panel\Desktop:LogPixels. The type is REG_DWORD.

You can see the Registry methods here to help how to modify the registry values.

Setting the value to 96 (0x60) corresponds setting the DPI settings to "Smaller" (100%).

  • 96 is "Smaller" (100%),
  • 120 is "Medium" (125%),
  • 144 is "Larger" (150%).

Note that the computer may still require a reboot or logout/login to make everything work as expected with that setting.

Gabe
  • 84,912
  • 12
  • 139
  • 238
  • I know. I have had the same problem. But I am afraid that there is no way to work around a restart. – Casper Taylor Korshøj May 27 '14 at 10:02
  • "60" as you refer to is actually 0x00000060. This is the registry key's value in hexadecimal and this value (0x00000060) is the same as the decimal value 96. You can see the decimal value 96 in the parentheses when using RegEdit. 0x00000060 = 96 = 100%, 0x00000078 = 96 = 125%, 0x00000090 = 96 = 150%. – Casper Taylor Korshøj May 27 '14 at 10:47
0

you have to use ViewBox in your applicaion.

It does nothing more than scale to fit the content to the available size. It does not resize the content, but it transforms it. This means that also all text sizes and line widths were scaled. Its about the same behavior as if you set the Stretch property on an Image or Path to Uniform.

for eample

  <Viewbox Stretch="Uniform">
      <Button Content="Test" />
    </Viewbox>
Dhaval Patel
  • 7,471
  • 6
  • 37
  • 70