Is the size of a Form in Visual Studio designer limited to screen resolution?

后端 未结 8 586
时光取名叫无心
时光取名叫无心 2020-11-27 19:13

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

8条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 19:56

    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);
    }
    

提交回复
热议问题