Windows.Forms.Panel 32767大小限制大小、Forms、Windows、Panel

2023-09-02 10:33:30 作者:拔刀为你战

我有一个使用 Windows.Forms.Panel 来显示图像列表的应用程序。当面板的高度超过32767个像素的内容的其余部分被简单地切断

I have an application that uses Windows.Forms.Panel to display a list of pictures. When the height of the panel exceeds 32767 pixels the rest of the content is simply cut off.

例如:

Windows.Forms.Panel myPanel;

ArrayList pictureList;

foreach(pic in pictureList) {
    myPanel.Controls.Add(pic) // adds all the objects without complaints
}

在这个例子中的所有元素都添加到面板上没有一个错误被抛出,但经过小组已达到32767大小没有图像不再显示。

In the example all elements are add to the panel without an error to be thrown, but after the panel has reached a size of 32767 no image is displayed anymore.

我的问题:是否有可能突破这个限制,并显示在面板上更多的内容

My question: Is it possible to break this limit and display more content in a panel?

据了解,现在的做法是inconvinient以任何方式,但没有时间,现在重新设计整个应用程序。

I know that the approach is inconvinient in any way, but there is no time now to redesign the whole Application.

推荐答案

这是Windows的体系结构限制。各种消息指示位置中的一个窗口,像WM_MOUSEMOVE,报告在一个32位整数,16位为X和16位的Y位置的位置。因此,不能创建一个窗口,它比short.MaxValue大。这不完全是一个现实的问题,没有人有一个监视器的宽度大于32,767像素并不会很长一段时间来。

This is an architectural limitation in Windows. Various messages that indicate positions in a window, like WM_MOUSEMOVE, report the position in a 32-bit integer with 16-bits for the X and 16-bits for the Y-position. You therefore cannot create a window that's larger than short.MaxValue. This isn't exactly a real problem, nobody has a monitor that's wider than 32,767 pixels and won't for a long time to come.

您将不得不不同的方法来做这个。就像一个Paint方法使用Graphics.TranslateTransform()。

You'll have to do this differently. Like using Graphics.TranslateTransform() in a Paint method.

 
精彩推荐