问题描述
我搜索的论坛,我尝试了一些东西......但他们并没有真正似乎工作。让我奠定了我的问题。
我有我的笔记本电脑一个非常高的屏幕分辨率:1400×1050。我设计这个我的应用程序。
我的同事尝试过了他的笔记本电脑(其中有更低的分辨率),并且应用程序不适合在他的笔记本电脑。该按钮被拖出屏幕空间。
所以,我希望我的应用程序自动调整/调整基于屏幕分辨率。我发现了一些类似论坛,我试图通过开发人员提出了一些东西,但是这并没有真正的工作对我来说。
我想: 解决方案1 :但正在改变用户的屏幕resution到位调整形式
我不希望使用最大化屏幕选项,并且不希望改变用户的PC设置。不幸的是我没有使用表布局面板。
请给我建议一个简单的解决方案。
OK,这是因为它得到差不多一样简单。只是遍历VB控制和调整基础上,新的屏幕分辨率达到了设计的屏幕分辨率比它们的大小。即是这样的:
昏暗DesignScreenWidth作为整数= 1600
昏暗DesignScreenHeight作为整数= 1200
昏暗CurrentScreenWidth作为整数= Screen.PrimaryScreen.Bounds.Width
昏暗CurrentScreenHeight作为整数= Screen.PrimaryScreen.Bounds.Height
昏暗RatioX为Double = CurrentScreenWidth / DesignScreenWidth
昏暗RatioY为Double = CurrentScreenHeight / DesignScreenHeight
对于每一个的iControl在Me.Controls
随着的iControl
如果(.GetType.GetProperty(宽度)。的CanRead)然后.WIDTH = CINT(.WIDTH * RatioX)
如果(.GetType.GetProperty(高)。的CanRead)然后.Height = CINT(.Height * RatioY)
如果(.GetType.GetProperty(顶部)。的CanRead)然后.TOP = CINT(.TOP * RatioX)
如果(.GetType.GetProperty(左)。的CanRead)然后。左= CINT(。左* RatioY)
结束与
下一个
请注意,我使用反射来看看每个控制了我们需要调整的性质。我做的方式是干净的,但使用后期绑定,并要求选项严格关闭。测试和认证。
I searched on the forums, and I tried a few things... but they didn't really seem to work. Let me lay out my problem.
I have a very high screen resolution on my laptop: 1400x1050. I'm designing my app on this.
My colleague tried it out on his laptop (which had lesser resolution), and the application did not fit on his laptop. The buttons were dragging out of the screen space.
So, I want my application to automatically resize/adjust based upon the screen resolution.I found some similar forums, and I tried a few things suggested by developers, but that did not really work out for me.
I tried : Solution 1 : But is changing user's screen resution in place of adjusting form .
I don't want to use Maximized screen option and don't want to change user's pc settings.Unfortunatly I am not using Table Layout panel.
Please suggest me a simple solution.
OK, this is just about as simple as it gets. Just iterate through the VB controls and adjust their sizes based on the ratio of the new screen resolution to your design screen resolution. i.e., something like:
Dim DesignScreenWidth As Integer = 1600
Dim DesignScreenHeight As Integer = 1200
Dim CurrentScreenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
Dim CurrentScreenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
Dim RatioX as Double = CurrentScreenWidth / DesignScreenWidth
Dim RatioY as Double = CurrentScreenHeight / DesignScreenHeight
For Each iControl In Me.Controls
With iControl
If (.GetType.GetProperty("Width").CanRead) Then .Width = CInt(.Width * RatioX)
If (.GetType.GetProperty("Height").CanRead) Then .Height = CInt(.Height * RatioY)
If (.GetType.GetProperty("Top").CanRead) Then .Top = CInt(.Top * RatioX)
If (.GetType.GetProperty("Left").CanRead) Then .Left = CInt(.Left * RatioY)
End With
Next
NOTE that I'm using reflection to see if each control has the properties we need to adjust. The way I'm doing it is clean but uses "late binding" and requires Option Strict Off. Tested and approved.
这篇关于更改分辨率形式的基于屏幕分辨率(不改变显示器的分辨率,并使用最大化屏幕的选项)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!