Delphi - 将表单最大化到特定屏幕

时间:2011-06-16 07:06:59

标签: delphi forms maximize-window

我会想到一个简单的问题,但我需要能够将表​​单最大化到特定的屏幕。似乎没有找到任何特定于Delphi的信息。

我可以记住后续应用程序加载时的表单位置。但是,当我恢复位置,然后调用WindowState := wsMaximized时,表单移动到另一个屏幕! (我确实在屏幕上也可以看到其他形式 - 它最大化为“活动屏幕”)

所以我需要一个像这样的函数:

procedure Maximize(const aScreenIndex : Integer);
begin
 if aScreenIndex < Screen.MonitorCount then
   //Maximize to that screen
end;

2 个答案:

答案 0 :(得分:5)

拦截WM_GETMINMAXINFO消息并根据需要调整其MINMAXINFO结构内的坐标。

答案 1 :(得分:1)

在设计时将Form.Position设置为poDesigned 在Form.FormShow或您的最大化过程中:

procedure Maximize(const aScreenIndex : Integer);
begin
  if aScreenIndex < Screen.MonitorCount then
  begin 
   //Maximize to that screen
    Myform.Left := screen.Monitors[aScreenIndex ].Left;
    Myform.WindowState := wsMaximized;
  end; 
end;
相关问题