MDI客户端更改了通知. [英] MDI Client changed notification.

查看:61
本文介绍了MDI客户端更改了通知.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WinForms表单类上,有一个名为IsMDIContainer的布尔类型属性,用于指示该表单是否是多文档接口(MDI)子表单的容器.也可以在运行时更改此属性,但是更改此属性值时不会引发任何事件.

有谁知道如何检测到这种变化?我已经尝试过对WM_STYLECHANGED消息使用WndProc,但是没有任何结果(确切地说,当我更改IsMDIContainer属性的值时,我从未通过WndProc收到此消息).谢谢.

On a WinForms form class, there is a bool type property named IsMDIContainer that indicate whether the form is a container for multiple-document interface (MDI) child forms. This property also can be changed in run-time, but there are no event raised when this property value is changed.

Is anyone knows how to detect that changes ? I have tried through WndProc on WM_STYLECHANGED message, but I have no result (exactly, I never receive this message through WndProc when I changed the value of the IsMDIContainer property). Thanks.

推荐答案

我不认为这样的事件存在.如果要在原始Windows API中找到样式更改,请查看Windows文档中的WS_ *常量.您只会找到扩展样式WS_EX_MDICHILD,而找不到与MDI父级关联的样式.据我所记得的背景,顶级窗口不能是MDI(父或子)窗口,而是具有另一个窗口,该窗口占据了顶级窗口客户区的整个区域.这是一个特殊的窗口,称为"MDI客户".并且只有MDI客户可以是MDI子级的父级.无论如何,使用P/Invoke是不好的,因为它破坏了应用程序的平台兼容性.

也许找不到您希望的Window消息或.NET事件,因为没有人在清晰的内存中并且头脑清醒地不打算更改此属性值,而不必处理应该在此更改上触发的事件. (顺便说一句,您想在自己的代码中修改此属性(仅为什么?!),您可以在从Form派生的类中创建您自己的事件.)为什么?

我有一个更好的主意:谁曾经需要MDI?为什么要折磨自己并吓users用户?
帮自己一个忙:完全不要使用MDI.没有设计,您可以更轻松地实现设计,并且质量更高.即使Microsoft也不鼓励使用MDI,实际上,Microsoft已将其从WPF中删除,并且几乎不支持它.更重要的是,如果您使用MDI,则会吓跑所有用户.只是不要.我可以解释该怎么办.

请参阅:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [如何在WPF中创建MDI父窗口? [ ^ ].

我可以告诉你可以用什么代替.

请查看我过去的答案:
在WPF中使用MDI窗口的问题 [ ^ ],
MDIContainer提供错误 [如何最大程度地设置子表单,最小化最后一个子表单 [ ^ ].

—SA
I don''t think such event exists. If you want to find the style change in raw Windows API, you cal look at WS_* constants in Windows documentation. You will find only the extended style WS_EX_MDICHILD, but not a style associated with a MDI parent. As far as I remember the background, top-level window cannot be a MDI one (parent or child), instead, it has another window which take the whole area of the top-level window''s client area. This is a special window called "MDI client"; and only the MDI client can be a parent of MDI children. Anyway, using P/Invoke is bad, because it breaks platform compatibility of your application.

Perhaps neither a Window message nor a .NET event you are hoping for is not found because nobody in clear memory and sober mind is not going to change this property value, forget about handling an event supposedly fired on this change. (By the way, as you want modify this property in your own code (only why?!), you could create your own event in your class derived from the Form.) Why?

I have a better idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don''t. I can explain what to do instead.

Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
How to Create MDI Parent Window in WPF?[^].

I can tell you what you could use instead.

Please see my past answers:
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last childform minimized[^].

—SA


这篇关于MDI客户端更改了通知.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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