如何阻止窗体超出窗口高度?

时间:2011-04-05 07:38:19

标签: delphi

我的表单超出了窗口的高度(当我使用拆分器时,它会改变面板的高度,从而改变窗体的大小)。

如何阻止它像这样调整大小?

1 个答案:

答案 0 :(得分:3)

我假设你自己正在改变表单大小,因为我找不到让分割器自动完成的方法。您可以使用Screen单元中的Forms对象获取屏幕的高度。您只需针对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;
相关问题