子窗体使用整个客户区?

发布于 2024-07-28 08:37:57 字数 844 浏览 2 评论 0原文

我想显示一个 MDI 子窗口,它将使用整个客户区,即。 灰色部分没有任务窗格的右侧,并让子窗口显示其标题栏和边框:

http://img149.imageshack.us/img149/3204/delphimdichildwindowwit.jpg

这是代码,它无法按计划工作:

procedure TForm1.RzGroup1Items0Click(Sender: TObject);
var
  Form2 : TForm2;
begin
  Form2 := TForm2.Create(Application);

  //BAD : doesn't start at 0,0, and triggers horizontal scrollbar
  Form2.Align := alClient;

  //BAD : doesn't show titlebar and borders
  Form2.WindowState := wsMaximized;

  //BAD : window exceeds width -> horizontal scrollbar shown
  Form2.top     := 0;
  Form2.Left    := 0;
  Form2.Width   := Self.ClientWidth;
  Form2.Height  := Self.ClientHeight;
end;

除了自己计算坐标之外,还有其他方法可以做到这一点(例如客户端宽度等)?

谢谢。

I'd like to show an MDI child window that will use the whole client area, ie. the grey part no the right-side of the taskpane, and have the child window show its titlebar and borders:

http://img149.imageshack.us/img149/3204/delphimdichildwindowwit.jpg

Here's the code, which doesn't work as planned:

procedure TForm1.RzGroup1Items0Click(Sender: TObject);
var
  Form2 : TForm2;
begin
  Form2 := TForm2.Create(Application);

  //BAD : doesn't start at 0,0, and triggers horizontal scrollbar
  Form2.Align := alClient;

  //BAD : doesn't show titlebar and borders
  Form2.WindowState := wsMaximized;

  //BAD : window exceeds width -> horizontal scrollbar shown
  Form2.top     := 0;
  Form2.Left    := 0;
  Form2.Width   := Self.ClientWidth;
  Form2.Height  := Self.ClientHeight;
end;

Is there a way to do this, besides computing the coordinates myself (eg. ClientWidth, etc.)?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅浅淡淡 2024-08-04 08:38:01

最快的方法是使用 TILE 命令。

var
  wFrm : TChildMDI;
begin
  wFrm := TChildMDI.create(self);
  wFrm.Show;
  Tile;
end;

TILE 是 TForm 的一种方法,如果您只有 1 个 MDI 子窗口,它将完全按照您的要求执行。 如果超过 1,它将排列所有可见的子窗口以适应类似的布局。

瑞安.

The quickest way to do that would be the TILE command.

var
  wFrm : TChildMDI;
begin
  wFrm := TChildMDI.create(self);
  wFrm.Show;
  Tile;
end;

TILE is a method of TForm and if you only have 1 MDI child window it will do exactly what you want. With more that 1 it will then arrange all the visible child windows to fit in a similar layout.

Ryan.

染墨丶若流云 2024-08-04 08:38:00

以下代码将为您提供 MDI 客户区的矩形。 请注意,对抗 MDI 是很困难的。

Form2.BoundsRect := GetMDIClientAreaBoundsRect(Form1);

function GetMDIClientAreaBoundsRect(MDIForm: TForm): TRect;
begin
  if MDIForm.FormStyle = fsMDIForm then begin
    if not Windows.GetClientRect(MDIForm.ClientHandle, Result) then
      RaiseLastOSError;
  end
  else
    raise Exception.Create('MDIForm is not an MDI form');
end;

The following code will give you the rect of the MDI client area. Please note that fighting MDI is hard.

Form2.BoundsRect := GetMDIClientAreaBoundsRect(Form1);

function GetMDIClientAreaBoundsRect(MDIForm: TForm): TRect;
begin
  if MDIForm.FormStyle = fsMDIForm then begin
    if not Windows.GetClientRect(MDIForm.ClientHandle, Result) then
      RaiseLastOSError;
  end
  else
    raise Exception.Create('MDIForm is not an MDI form');
end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文