表格'所有者'财产 [英] Forms 'owner' property

查看:84
本文介绍了表格'所有者'财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在寻找答案是否有任何方法可以做到父母表格(所有者)总是在顶部?当我使用所有者属性时,子表单总是在顶部,我知道这是正确的(我在msdn上找到它)。我想创建接口,如GIMP ,带有图标的小面板(打开,保存,许多效果等)始终位于顶部,以及包含图像的窗口。任何人都可以帮助我或让我自己写一切 - 所有事件,如父母关闭时的关闭,儿童参考数组等?有没有人有这样的界面教程? 我不是在寻找MDI应用,因为子窗口在父窗口内。

解决方案

请参阅我对该问题的评论。



首先,永远在上面由属性 System.Windows.Forms.TopMost

http://msdn.microsoft.com /en-us/library/system.windows.forms.form.topmost.aspx [ ^ ]。



不要混淆 TopLevel 默认值为false的属性使表单之间的父子关系有效地不存在。不要改变这种行为,不要试图使表格成为非顶级。如果你这样做,你实际上可以让一个形式成为任何控制的孩子,但是...更好的,甚至不尝试,这是不好的。



最后,所有者是一个非常重要的属性。如果你有一个以上的表格(我不认为MDI,它也没有好处),所有表格通过所有权关系连接,使你的应用程序在表单激活方面保持一致。为了实现这一点,它足以使主表单拥有所有表单。在这种情况下,当您激活任何形式的应用程序时,所有其他表单也会以Z顺序排在最前面,而您的活动表单位于最顶层。换句话说,它可以将所有表单一起激活,不允许任何其他应用程序的窗口介入您的窗口之间。



为了补充这种方便的设计,它'对于除主要表单之外的所有表单,使用值 ShowInTaskbar 为false也很重要。这样,只有一个表单图标代表任务栏中的整个应用程序。



我的最终建议是:在大多数情况下,最好的设计只有一个形成。 (添加少量的模态表单虽然很好。)在这种情况下,您作为单独表单使用的内容由面板,标签页等表示。



< DD> -SA

Hi there, i''m looking for an answer is there any way to do that parent form (owner) will be always on top? When i''m using owner property child forms are always on top and i know that is correct ( i found it on msdn). I''d like to create interface like GIMP, small panel with icons (open, save, many effects etc) which is always on top, and windows that contain image. Can anyone help me with that or have i to write everything on my own- all events like closing when parent is closing, array of child references etc? Does anyone has any tutorial for interface like that? I''m not looking for MDI applictation becouse there child windows are inside parent windows.

解决方案

Please see my comments to the question.

First, "always on top" is controlled by the property System.Windows.Forms.TopMost:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.topmost.aspx[^].

Don''t mix it up with TopLevel the property which default value of false keeps parent-child relationships between forms effectively defunct. Don''t change this behavior and don''t try to make a form a non-top level. If you do it, you can actually make a form a child of any control, but… better don''t even try, it''s no good.

Finally, Owner is a very important property. If you have more then one forms (I don''t consider MDI, it''s also no good), having all of your forms connecter by ownership relationship makes your application consistent in respect to form activation. To achieve that, it''s enough to make all forms owned by the main form. In this case, when you activate any form of your applications, all other forms also go on top in Z-order, with your active form on the very top. In other words, it keeps all your forms activate together, not allowing a window of any other application to meddle in between yours.

To complement this convenient design, it''s also important to use the value ShowInTaskbar of false, for all forms except the main one. This way, only one form icon represents the whole application in the task bar.

My final recommendation is: in most cases, the best design is the one having only one form. (Adding a small number of modal forms is fine though.) In this case, what you use as separate form are represented by panels, tab pages, etc.

—SA


这篇关于表格'所有者'财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆