SetCapture, mouse and key events




I'm trying to modify one of the Scribble sample apps (C#) such that the user
can draw w/o holding the mouse button down. That is, the first mouse click
turns on drawing, and the second mouse click turns it off.
In the MouseUpHandler, I set the Capture property:
this.Capture = true;

I put some TRACE output in the MouseMove handler; when the cursor leaves the
mdi child window, it stops getting the mouse messages. I thought the
Capture property would make sure the window gets all mouse messages until
some other window captured the mouse. Also, after setting Capture to true
in the mouseup handler (after calling base.OnMouseUp()), Capture is _false_
in the mousemove handler...

How can I get the desired behavior? I'm just experimenting with this app;
eventually, I'll be drawing rubber band shapes and I need to have the rubber
band drawing track with the mouse, even when it is outside the client

Also, when a window has 'captured' the mouse, should it get all the keyboard
input as well, or does something else need to be done? For example, in a
differnt app, when I am drawing a rubber rectangle with the mouse button
held down, my shortcut key to bring up the Open File dialog still works.

TIA for any ideas.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question