Visual Studio 设计器中表单的大小是否受限于屏幕分辨率? [英] Is the size of a Form in Visual Studio designer limited to screen resolution?

查看:13
本文介绍了Visual Studio 设计器中表单的大小是否受限于屏幕分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在 Visual Studio WinForms 设计器中,我无法将表单的大小增加到我当前正在处理的屏幕分辨率之上?我认为应该有可能以某种方式在较低分辨率的系统上开发针对较高分辨率的应用程序.在调试期间这会剪辑表单的事实不应该是一个问题.Visual Studio 中是否有一些设置,我似乎找不到?

Why is it, that in the Visual Studio WinForms designer I cannot increase the size of my Form above the resolution of the screen I am currently working on? I think it should somehow be possible to develop an application aimed at higher resolutions on a lower res system. The fact that this would clip the Form during debugging should not be an issue. Is there perhaps some setting in Visual Studio for this, which I cannot seem to find?

我的主要问题是我需要能够在具有(例如)1360x768 屏幕的笔记本电脑上设计(例如)1440x900 大小的表单.

My main issue is that I need to be able to design a (for example) 1440x900 sized form on a laptop with a (for example) 1360x768 screen.

推荐答案

不幸的是(我希望其他人能发布更好的解决方案!),我知道的唯一解决方法是在表单中放置一个面板.

Unfortunately (I hope someone else will post a better solution!), the only workaround I'm aware of is to place a panel inside the form.

将父窗体的 AutoscrollAutoSize 属性设置为 true.然后将面板尺寸增加到所需的尺寸.表单本身仍然不会比您的屏幕分辨率更大,但它会显示滚动条,因此至少您可以使用设计器将超出尺寸限制的控件等放到更大的面板上.

Set the Autoscroll and AutoSize properties of the Parent Form to true. Then increase the panel size to the desired size. The form itself will still not get any larger than your screen resolution, but it will show scroll bars, so at least you can use the designer to drop controls etc beyond your size limitations onto the larger panel.

然后,您可能需要添加一些代码来在运行时调整表单大小,使其足够大以显示没有滚动条的面板(并且可能还禁用 Autoscroll 属性).

Then, you may need to add some code to adjust the the forms size at run-time so that it is large enough to show the panel without scroll bars (and perhaps also disable the Autoscroll property).

我知道,这不是一个特别好的解决方法......

I know, It's not a particularly nice workaround...

编辑:

看起来这是有意为之:

MSDN

属性形式.大小:此属性的最大值受限于表单运行的屏幕分辨率.值不能每个屏幕尺寸大于 12 个像素(水平 + 12和垂直 + 12).

Property Form.Size: The maximum value of this property is limited by the resolution of the screen on which the form runs. The value cannot be greater than 12 pixels over each screen dimension (horizontal + 12 and vertical + 12).

再次在 Microsoft Connect/公共错误跟踪:

Microsoft 于 2008 年 10 月 9 日上午 12:18 发布

感谢您的反馈在 .NET 框架上!

Thanks for your feedback on the .NET Framework!

您报告的问题实际上是设计使然.

The issue that you have reported is actually By Design.

在 MSDN 中 http://msdn.microsoft.com/en-us/library/25w4thew.aspx,你可以在主题 Form.Size 属性中找到以下信息:

In MSDN at http://msdn.microsoft.com/en-us/library/25w4thew.aspx, you can find the following information at the topic Form.Size Property:

该属性的最大值受分辨率的限制窗体运行的屏幕.该值不能大于 12每个屏幕维度上的像素(水平 + 12 和垂直 + 12).

The maximum value of this property is limited by the resolution of the screen on which the form runs. The value cannot be greater than 12 pixels over each screen dimension (horizontal + 12 and vertical + 12).

因此,我们不能无限地放大我们的表格.这种行为是与记事本、微软画图等其他软件保持一致.

Therefore, we can't enlarge our forms indefinitely. This behavior is consistent with other software, such as Notepad and Microsoft Paint.

此行为在蛾类 Form.SetBoundsCore(...) 中定义以下代码:

This behavior is defined in the mothed Form.SetBoundsCore(...) with the following code:

最大尺寸 = SystemInformation.MaxWindowTrackSize;

Size max = SystemInformation.MaxWindowTrackSize;

if (height > max.Height) {

if (height > max.Height) {

height = max.Height; }

if (width > max.Width) {

if (width > max.Width) {

width = max.Width; }

[...]

感谢 UIFx 团队

EDIT2:

由于检查是在 Forms.SetBoundsCore 中硬编码的(使用 ILSpy 作为反编译器):

Since the check is hardcoded in Forms.SetBoundsCore like (using ILSpy as a decompiler):

if (this.WindowState == FormWindowState.Normal && (base.Height != height || base.Width != width))
    {
        Size maxWindowTrackSize = SystemInformation.MaxWindowTrackSize;
        if (height > maxWindowTrackSize.Height)
        {
            height = maxWindowTrackSize.Height;
        }
        if (width > maxWindowTrackSize.Width)
        {
            width = maxWindowTrackSize.Width;
        }
    }

并且 SetBoundsCore 是一个受保护的函数,也许您可​​以尝试从 Windows.Forms.Form 派生一个类,覆盖 SetBoundsCore 并且不要在您的 SetBoundsCore 版本中强制执行此检查?我还没试过它是否有效...

and SetBoundsCore is a protected function, perhaps you could try deriving a class from Windows.Forms.Form, override SetBoundsCore and don't enforce this check in your version of SetBoundsCore? I haven't tried if it works though...

这篇关于Visual Studio 设计器中表单的大小是否受限于屏幕分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆