SetCapture not caputring mouse events for me

G

Guest

I mught have misunderstood how SetCapture works, but I call it passing my
form's Handle and I am not noticing any difference in what mouse events my
app is picking up. It is only limited to mouse events within my control,
which is the same way it worked with just setting a mouse event handler
directly.


What I desire is to capture mouse events accross the entire system, whether
I click in my window or another window... SetCapture doesn't do that? If so,
what do I need to do to get that behavior?
 
G

Guest

Wait, do I need VS 2005 (framework 2.0) to be able to use this feature? I
have VS 2003...
 
N

Nicholas Paldino [.NET/C# MVP]

From the documentation for SetCapture:
The SetCapture function sets the mouse capture to the specified window
belonging to the current thread. SetCapture captures mouse input either when
the mouse is over the capturing window, or when the mouse button was pressed
while the mouse was over the capturing window and the button is still down.
Only one window at a time can capture the mouse.

If the mouse cursor is over a window created by another thread, the system
will direct mouse input to the specified window only if a mouse button is
down.

If you want to capture mouse events across the entire system, then you
have to create a windows hook (which I don't know you can do system-wide in
C#).
 
G

Guest

Hmm, would it be at all possible to detect whenever a window gain focus and
then immediately call SetCapture on that window?

So as the user changes focus to different programs, I run code to SetCapture
on those programs?

How can I get a list of IntPtr's to currently active programs running, which
I can make WinAPI calls with ?
 
N

Nicholas Paldino [.NET/C# MVP]

Calling SetCapture on windows that you don't have control on doesn't
make much sense. It's not going to do anything for you.

Can you explain from a higher level what it is you are trying to do?
 
G

Guest

Yes, in all likelihood I am barking up the wrong tree with SetCapture!

I want to find out where the user clicks on (the mouse coordinates) anywhere
in windows, whether it's within the scope of the app currently running or
some other app gaining focus.

Then later I want to get the pixel data for those coordinates.
 

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

Top