MDI形式“蠕变” (MDI窗口中的位置变化)

发布于 2024-07-11 07:24:15 字数 368 浏览 5 评论 0原文

我有一个 VB.NET MDI WinForms 应用程序。 我的用户一直在抱怨表单蠕变(他们这样称呼它),这是每次您在主 MDI 窗口中打开特定表单时,它会在之前加载的位置的稍下方和右侧打开 - 即它从窗口的左上角,然后向下移动到右下角。

我必须同意他们的观点,这非常令人恼火,有什么办法可以防止这种情况发生吗? 加载表单的代码是:

frmPurchaseInvoiceSelect.Show()
frmPurchaseInvoiceSelect.MdiParent = Me

我可以通过将表单启动位置设置为“手动”来解决这个问题,但随后它们只是在屏幕左上角直接打开。

还有其他 SO 用户遇到过这个吗?

I have a VB.NET MDI WinForms app. My users have been complaining about form creep (as they call it), this is where each time you open a specific form within the main MDI window it opens slightly below and to the right of the location it loaded previously - i.e. it starts in the top left of the window and works its way down to the bottom right.

I have to agree with them that this is extremely irritating, is there any way to prevent this? The code to load the forms is:

frmPurchaseInvoiceSelect.Show()
frmPurchaseInvoiceSelect.MdiParent = Me

I can address this somewhat by setting the forms start-up positions to 'Manual' but then they just open directly on top of each other in the top left of the screen.

Any other SO users come across this?

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

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

发布评论

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

评论(5

还不是爱你 2024-07-18 07:24:15

尝试使用

frmPurchaseInvoiceSelect.StartPosition = FromStartPosition.CenterParent

始终从 Mdi 父级的中心开始。

有几个选项,但这取决于您希望表单从哪里开始。 我还没有尝试过,但是:

frmPurchaseInvoiceSelect.Location = windowPoint
frmPurchaseInvoiceSelect.Size = windowSize
frmPurchaseInvoiceSelect.StartPosition = FormStartPosition.Manual  

应该在您想要的位置开始表单。

Try

frmPurchaseInvoiceSelect.StartPosition = FromStartPosition.CenterParent

to always start in the centre of the Mdi parent.

There are a few options but it depends on where you would like the form to start. I haven't tried it but:

frmPurchaseInvoiceSelect.Location = windowPoint
frmPurchaseInvoiceSelect.Size = windowSize
frmPurchaseInvoiceSelect.StartPosition = FormStartPosition.Manual  

should start the form exactly where you want.

多像笑话 2024-07-18 07:24:15

以下为我解决了这个问题
frmUser.StartPosition = FormStartPosition.Manual
当重新打开时,它停止“爬行”

The following resolved it for me
frmUser.StartPosition = FormStartPosition.Manual
when reopened, it stopped 'creeping'

愁杀 2024-07-18 07:24:15

请参阅我的问题和结果答案这可能会帮助你解决这个问题。 您还可以查看我非常详细的博客 关于该主题的条目。 我的代码是用 Delphi 编写的,但您应该能够将这些概念转移到 VB。

See my question and the resulting answer which might well help you with this problem. You can also look at my very verbose blog entry on the subject. My code is written in Delphi but you should be able to transfer the concepts to VB.

稀香 2024-07-18 07:24:15

无论使用哪种语言,原因都是相同的。 当您打开第一个 MDI 窗口时,起始点相对于 MDI 框架为 0,0,因此它在框架内的左上角打开。 如果您关闭窗口然后重新打开它,起始点不再是 0,0 而是基于您打开窗口的方式(级联等)的其他值。通常,它会稍微低一些,位于上一个窗口的右侧。关闭。 存在问题的原因是您或工具没有检查要打开的窗口是否是框架内唯一的窗口实例。 如果该窗口是唯一的实例,则在 0,0 处打开它,否则在相对于其他窗口的适当位置打开它。

此功能通常由您正在使用的 MDI 库处理,或者如果没有,您将手动编码。 手动编码只需几行,因此实施起来应该很简单。

Regardless of the language used, the cause is the same. When you open the first MDI window, the starting point is 0,0 relative to the MDI frame so it opens top left within the frame. If you close the window and then reopen it, the starting point is no longer 0,0 but some other value based on how you open windows (cascade, etc) Generally it will be slightly lower and to the right of the previous window which was closed. The problem exists because you or the tool are not checking to see if the window about to be opened is the only window instance within the frame. If the window is the only instance, open it at 0,0, otherwise open it at the appropriate position relative to the other windows.

This functionality would be usually handled by the MDI library you are using, or if not, you would code it manually. It only takes a few lines to code it manually so it should be trivial to implement.

烟酉 2024-07-18 07:24:15

MBoy,

MDI 应用程序通常不显示居中的窗口,尽管 SDI 应用程序可以。
在打开多个窗口的 MDI 应用程序中,用户通常希望看到每个窗口的边缘(级联视图),以便他/她可以单击所需的窗口将其置于前面。 这通常可以通过两种方式完成。 了解打开的窗口数量以及它们相对于 MDI 框架的位置。 打开最后一个窗口下方和右侧的后续窗口。 此功能通常在所使用的语言或库中提供。 第二种方法是选择(菜单或其他方式)以所需的方向(级联、平铺或分层)显示打开的窗口。 正如我之前提到的,如果语言/库中未自动提供 MDI 显示功能,则需要手动编码。 这可以在每个 MDI 窗口打开时但在其变得可见之前调用的函数中完成。

MBoy,

MDI applications do not usually display windows centered although SDI applications may.
In an MDI application with multiple windows open, a user generally wants to see the edge of each window (cascaded view) so that he/she can click on the desired window to bring it to the front. This can normally be done 2 ways. Know how many windows are open and their positions relative to the MDI frame. Open subsequent windows just below and to the right of the last window. This functionality is usually provided within the language or library used. The second way is to have a selection (menu or otherwise) to display the opened windows after the fact in the desired orientation (cascaded, tiled, or layered). As I mentioned before, if MDI display functionality is not provided automatically within the language/library, it will need to be coded manually. This can be done in a function which is called when each MDI window is opened but before it becomes visible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文