简体   繁体   中英

Trap mouse clicks outside of modal dialog

I have an application written in C# targeting .NET Compact Framework 3.5, running on Windows CE. I would like to provide a custom visual cue in a modal dialog if the user tries to interact with its owner window without closing the dialog first.

Is it possible for a modal dialog to receive notifications of mouse clicks on its owner window? The owner window is running in full screen, so it would be sufficient to trap clicks outside of the modal dialog in general.

This is how modality works. When a dialog is shown modally (CE or desktop Windows) that window gets it's own internal message pump. What that means is that wehn you get a message (like a mouse down) outside of your Window, the pump discards it. There's no way for the pump to dispatch that message "up" the chain to another pump (well not without you mucking with both pumps yourself - it's possible yes, but complex, convoluted, and not at all scalable or maintainable).

您可能使用Control.Capture属性。

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