我的应用程序在默认的100%下运行良好,但是如果用户已将屏幕更改为125%或其他内容,则组容器的运行时大小调整以及表单大小本身会失败。我错过了什么?根据条件,在表单上重新定位组框,并调整表单的大小。我通过将我的系统重新设置为125%并调整运行时重新定位控件和表单来确认这一点,然后就可以了。
答案 0 :(得分:0)
这是我所做的,目前它正在发挥作用:
在项目中添加了App.manifest,添加了以下代码:
<asmv1:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true/PM</dpiAware>
</asmv1:windowsSettings>
在我的启动表单中添加了以下子项:
Private Sub GetScreenDPI()
Dim dspGraphics As Graphics
dspGraphics = Me.CreateGraphics 'Graphics for user's display
g_int_ScreenDPI = dspGraphics.DpiY
Select Case g_int_ScreenDPI
Case 96 'Smaller 100%
g_dbl_screenDPI = 1
Case 120 'Medium 125%
g_dbl_screenDPI = 1.25
Case 150 'Larger 150%
g_dbl_screenDPI = 1.5
Case Else 'Custom
g_dbl_screenDPI = g_int_ScreenDPI / 100
End Select
dspGraphics.Dispose()
End Sub
我需要扩展控件或形成位置:
Me.Height = CInt(550 * g_dbl_screenDPI)