I need to get mouse events anywhere on the screen
-
I need to catch mouse events, even when the mouse is not over any of my forms or controls. Ideally, I could selectively choose to either pass on the message to the window that should have gotten it, or trap it. Anybody have an idea?
Fortunately, there is no C# way of doing this : mouse events are attached to controls.
if you start putting in too manay features, it no longer remains useful for beginners quote in a CP article comment, shiraz baig
-
Fortunately, there is no C# way of doing this : mouse events are attached to controls.
if you start putting in too manay features, it no longer remains useful for beginners quote in a CP article comment, shiraz baig
-
I need to catch mouse events, even when the mouse is not over any of my forms or controls. Ideally, I could selectively choose to either pass on the message to the window that should have gotten it, or trap it. Anybody have an idea?
I don't if it works or not. Because I've never used this feature Correct me if I am wrong:) There is a property called Capture in Control Class. It can be set to true if you wish to capture all mouse events, even outside the control's borders. The following text is copied from MSDN: --- When a control has captured the mouse, it receives mouse input whether or not the cursor is within its borders. The mouse is typically only captured during drag operations. Only the foreground window can capture the mouse. When a background window attempts to do so, the window receives messages only for mouse events that occur when the mouse cursor is within the visible portion of the window. Also, even if the foreground window has captured the mouse, the user can still click another window, bringing it to the foreground. When the mouse is captured, shortcut keys do not work. --- Hope this would help:-O
-
I don't if it works or not. Because I've never used this feature Correct me if I am wrong:) There is a property called Capture in Control Class. It can be set to true if you wish to capture all mouse events, even outside the control's borders. The following text is copied from MSDN: --- When a control has captured the mouse, it receives mouse input whether or not the cursor is within its borders. The mouse is typically only captured during drag operations. Only the foreground window can capture the mouse. When a background window attempts to do so, the window receives messages only for mouse events that occur when the mouse cursor is within the visible portion of the window. Also, even if the foreground window has captured the mouse, the user can still click another window, bringing it to the foreground. When the mouse is captured, shortcut keys do not work. --- Hope this would help:-O
just tested it. It looks the scope is rather limited. Even you set it true, you still can't capture mouse events outside its top parent control...
-
just tested it. It looks the scope is rather limited. Even you set it true, you still can't capture mouse events outside its top parent control...
-
Hmmm, that isn't very helpful in this situation, but good to know overall. Anybody else?
there's useful project on "the evil other site" ;) http://www.codeguru.com/system/Lock.shtml the secret is: you need to install a system-hook. the one capturing mouse-events needs to reside in a dll. i once did that with C++ but i have no idea whether this works with C#... :~ :wq