English 中文(简体)
通过登记册在程序上更改 dpi 设置?
原标题:Change dpi settings via registry programmatically?
  • 时间:2012-05-26 05:58:16
  •  标签:
  • vb.net
  • dpi

I ve designed a project containing of some forms. The problem is that it doesn t display correctly on wide monitors. I ve searched for it and found out that it works correctly for dpi= 96. I wanna change dpi via registry in vb.net (not manually) Here is the code I use:

    Dim dpi As Graphics = Me.CreateGraphics
    If (dpi.DpiX <> 96 And dpi.DpiY <> 96) Then
        Dim DPISetting As RegistryKey = My.Computer.Registry.CurrentUser.OpenSubKey("HKEY_CURRENT_USERControl PanelDesktopWindowsMetrics", True)
        DPISetting.SetValue("AppliedDPI", 96)  **
    End If

但我在 ** 的线条上得到了一个“ 取消重复” 例外。 对象引用没有设定一个对象的例子。 我花了很长时间才真正研究它,但找不到问题所在。 如果您有任何建议或解决办法, 我非常感激 。

问题回答

<强> 此设计根本中断 。

< a href=> http://blogs.msdn.com/b/oldnewthing/archive/2008/12/11/91939.aspx" rel=“nofollow norefererr”> 您的应用程序应该 not 改变一个全球系统设置, 仅用于在代码中的错误周围工作。 这是保证您的用户立即解密您的应用程序, 并永远不再使用该应用程序的好方法。 如果您运气好, 他们不会告诉朋友。 您通常不会这么幸运 。

而不是试图使黑客工作, 为什么不只解决实际问题呢? 如果您的表格没有在高( 低) DPI 设置中正确显示, 您需要让它在这些情景中发挥作用。 这是开发桌面应用程序的一部分 — — 确保您的应用程序在不同环境中运作。

为此,你可能认为这些答复中的建议是有益的:





相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签