Overcome OS Imposed Windows Form Minimum Size Limit

前端 未结 6 707
耶瑟儿~
耶瑟儿~ 2020-11-29 08:57

In an application I am developing, I need to be able to make a windows form smaller than the minimum height limit imposed by the operating system (36 px in Vista). I have t

6条回答
  •  醉梦人生
    2020-11-29 09:25

    When playing with minimum form size, I noticed, that minimum form size is restricted to system minimum form size in Form.SetBoundsCore(...). When I look into IL disassemly, I found, that this .Net method always corrects what you give it (width and height) to SystemInformation.MinimumWindowSize if they are smaller and the form don't have a parent and its FormBorderStyle is FixedSingle, Fixed3D, FixedDialog or Sizable.

    The easiest solution to this problem is not handling WM_WINDOWPOSCHANGING, but simply setting FormBorderStyle = System.Windows.Forms.FormBorderStyle.None in the form constructor.

提交回复
热议问题