简体   繁体   English

陷阱鼠标在模态对话框之外单击

[英]Trap mouse clicks outside of modal dialog

I have an application written in C# targeting .NET Compact Framework 3.5, running on Windows CE. 我有一个用C#编写的,针对.NET Compact Framework 3.5的应用程序,该应用程序在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. 当对话框以模态显示时(CE或桌面Windows),该窗口将获得其自己的内部消息泵。 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属性。

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

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