2011-04-05 18 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;