简体   繁体   中英

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?

For example, the system's own MessageBox, clicking on the parent window, will have flashing animation.

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. 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.

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 .

Of course, to get this information you need to override WindowProc of your window first, which in WPF is a separate fun. 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. But I really advise you to think several times before going in this direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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