Winforms MDI 客户端区域的大小/位置

发布于 2024-07-14 00:33:17 字数 141 浏览 9 评论 0原文

MDI 表单内部有一个托管 MDI 子表单的客户区。 我如何知道该区域有多大? 到目前为止,我能想到的最好办法是找到父级潜在客户区域(mdiparent.ClientRectangle)的总大小,然后减去工具栏等从客户区域中带走的组件的大小。 有没有更好的办法?

Inside an MDI form is a client area that hosts the mdi child forms. How do I find out how big that area is? The best I can come up with so far is finding the total size of the parent's potential client area (mdiparent.ClientRectangle) and then subtracting off the sizes of components like toolbars, etc that take away from the client area. Is there a better way?

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

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

发布评论

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

评论(2

雄赳赳气昂昂 2024-07-21 00:33:17

窗体上没有任何属性可以让您访问 MDI 客户端窗口。 但您可以像这样找到它:

public MdiClient GetMdiClientWindow() {
  foreach (Control ctl in this.Controls) {
    if (ctl is MdiClient) return ctl as MdiClient;
  }
  return null;
}

从那里,只需使用它的 Size 属性。

There is no property on a form that gives you access to the MDI client window. But you can find it back like this:

public MdiClient GetMdiClientWindow() {
  foreach (Control ctl in this.Controls) {
    if (ctl is MdiClient) return ctl as MdiClient;
  }
  return null;
}

From there, just use its Size property.

夏尔 2024-07-21 00:33:17

下面是 vb.net 中该代码的变体:

Public Function GetMdiClientWindowSize() As Size
    For Each ctl As Control In Me.MdiParent.Controls
        If TypeOf ctl Is MdiClient Then
            Return ctl.Size
        End If
    Next
    Return Nothing
End Function

Here's a variant of that code in vb.net:

Public Function GetMdiClientWindowSize() As Size
    For Each ctl As Control In Me.MdiParent.Controls
        If TypeOf ctl Is MdiClient Then
            Return ctl.Size
        End If
    Next
    Return Nothing
End Function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文