简体   繁体   English

WPF ShowDialog 单击所有者窗口事件

[英]WPF ShowDialog Click owner Window Event

my English is not very good, I hope you can help me answer this question, hurry up, WPF when ShowDialog(), click on other parent form triggered events can be captured?我的英文不是很好,希望你能帮我回答这个问题,快点,WPF的时候ShowDialog(),点击其他父窗体触发的事件可以捕获吗?

For example, the system's own MessageBox, clicking on the parent window, will have flashing animation.比如系统自带的MessageBox,点击父窗口,会有闪烁的动画。

I want capture the event,Thank you我想捕获事件,谢谢

First of all, whatever your goal is in the end , it can probably be reached in a different way.首先,无论你的目标是在年底,大概可以用不同的方式达到。 I really encourage you to take several steps back, think twice and try to approach the problem from some different side before actually doing what you asked.我真的鼓励你退后几步,三思而后行,在实际做你要求的事情之前尝试从不同的方面解决问题。

As for your question, you don't have such an event in WPF.至于你的问题,你在WPF中没有这样的事件。 There is an answer, but there is no easy way.有一个答案,但没有简单的方法。 You'll have to guess and go low-level.您必须猜测并进行低级别。 And the guess will depend on the version of Windows it runs on.猜测将取决于它运行的 Windows 版本。

Anyway, you need to check the sequence of Window Messages that your owner form receives.无论如何,您需要检查您的所有者表单收到的窗口消息的顺序。 In Windows 8.1 owner form receives WM_WINDOWPOSCHANGING with lParam pointing to a structure whose flags are at least 0x13 : SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE .在 Windows 8.1 中,所有者表单接收WM_WINDOWPOSCHANGING,其中 lParam 指向flags至少为0x13 : SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE结构0x13 : SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE

Of course, to get this information you need to override WindowProc of your window first, which in WPF is a separate fun.当然,要获取此信息,您需要先覆盖窗口的 WindowProc,这在 WPF 中是一个单独的乐趣。 And additionally, the combination of parameters may also happen in other circumstances so you'll have to make sure to track somehow that you have a modal dialog open so that this kind of window message actually means the attempt to activate owner window.此外,参数组合也可能发生在其他情况下,因此您必须确保以某种方式跟踪您打开了一个模态对话框,以便这种窗口消息实际上意味着尝试激活所有者窗口。

It's low-level windows management, so you can do essentially everything.它是低级 Windows 管理,因此您基本上可以做任何事情。 But I really advise you to think several times before going in this direction.但我真的建议你在朝这个方向前进之前多考虑几次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM