2011-04-05 79 views
1

我的表格超过了窗口的高度(当我使用分隔符改变了面板的高度,这反过来改变了窗体的大小)。如何阻止表单超过窗口高度?

我该如何阻止它从这样的大小调整?

+0

如果表单“中变小”,玩分割器的最小尺寸,位置和对齐方式。当调整大小并重新调整其包含的控件和分割符时,VCL可能会错误地调整窗体大小。请参阅:http://stackoverflow.com/questions/4835617/how-do-i-avoid-this-unwanted-behaviour-with-delphis-tsplitter-and-panels关于此的更多信息。 – 2011-04-05 10:22:32

+0

你想“停止它调整大小”?你想阻止用户超过一定的大小,或者你想阻止你编写的改变高度的代码改变那个高度?我从来没有见过一个分离器INSIDE窗体改变外部窗体的高度。所以显然你在代码中已经做了一些奇怪的事情。 – 2011-04-05 15:42:26

回答

3

我假设你自己改变窗体大小,因为我找不到一种方法让分隔线自动完成。您可以使用Forms单位中的Screen对象获取屏幕的高度。你可以简单地测试对Screen.Height或者,如果你想更好地支持多显示器,测试针对Screen.MonitorFromWindow(Handle).Height

代码示例,未经检验的,应该让你开始:

var MaxFormHeight: Integer; 
    NewFormHeight: Integer; 
    M: TMonitor; 
begin 
    // Get the monitor that's hosting the form 
    M := M := Screen.MonitorFromWindow(Handle);  
    MaxFormHeight := M.WorkAreaRect.Bottom - M.WorkAreaRect.Top - Top; // Take into account actual available monitor space and the Top of the window 
    // Do your stuff to calculate NewFormHeight 
    if NewFormHeight > MaxFormHeight then 
    NewFormHeight := MaxFormHeight; 
    Height := NewFormHeight; 
end;