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?
EDIT: 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.
Select the form, then find the Properties pane in Visual Studio. Scroll down to size and expand it. You can set the Width and Height manually.
Automatic scaling in action At run time, the actual resolution is stored in the CurrentAutoScaleDimensions property. The AutoScaleFactor property dynamically calculates the ratio between the run-time and design-time scaling resolution.
To resize multiple controls on a form In Visual Studio, hold down the Ctrl or Shift key and select the controls you want to resize. The size of the first control you select is used for the other controls.
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.
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.
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...
EDIT:
Looks like this is intentional and by design:
MSDN
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).
and again at Microsoft Connect/Public Bug Tracking:
Posted by Microsoft on 10/9/2008 at 12:18 AM
Thanks for your feedback on the .NET Framework!
The issue that you have reported is actually By Design.
In MSDN at http://msdn.microsoft.com/en-us/library/25w4thew.aspx, you can find the following information at the topic Form.Size Property:
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.
This behavior is defined in the mothed Form.SetBoundsCore(...) with the following code:
Size max = SystemInformation.MaxWindowTrackSize;
if (height > max.Height) {
height = max.Height; }
if (width > max.Width) {
width = max.Width; }
[...]
Thanks, UIFx Team
EDIT2:
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;
}
}
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...
Thanks all, especially Ben Schwehn! With the info provided above, if your app uses a base form, you can make the following changes (in C#) which will remove the limitation from all forms inherited from it.
[DllImport("user32.dll", EntryPoint = "MoveWindow")]
private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int w, int h, bool repaint);
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
{
base.SetBoundsCore(x, y, width, height, specified);
MoveWindow(Handle, x, y, width, height, true);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With