views:

696

answers:

3

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.

A: 

You could probably use the Control.Capture property.

dommer
I'm not able to make this work. I set the Form's Capture property to true before calling the ShowDialog method, but I'm not receiving any Click events when clicking outside the dialog.
Tormod Fjeldskår
Is it possible that the form needs to be visible to have the capture set?
dommer
I've tried ensuring the Form is visible before setting the Capture property, but still no luck. Might be a Windows CE quirk...
Tormod Fjeldskår
A: 

This is not a Windows CE issue, I am having the same issue in Vista and Server 2008. My form's Capture property is true, but the events Click, MouseClick, and MouseDown do not fire if I click outside the form. Very disappointing. The Capture property does not appear to do what it says in the help file.

+1  A: 

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

ctacke