473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Receiving mouse events (WM_MOUSEMOVE, etc) outside of form

I'm trying to implement some pretty basic behavior in c#/.net 1.1
Forms but can't seem to find all the requisite pieces. When a user
clicks on the background of the form, I want the app to start
receiving MouseMove updates -- whether the pointer is over the form or
not (this being the crucial part) -- until the next MouseDown. It's
easy to receive MouseMove events while the pointer is over the form
but not when the pointer leaves. (Forms continue to receive
out-of-window MouseMove updates if a mouse-button is held down, ie a
drag, but not when just moving around.)

So, is there some simple way to do this in .NET?

The one approach that I've encounted which seems to have promise is
using the User32 SetCapture function. I can successfully capture the
mouse, but then I'm not sure how to receive the event messages
(specifically WM_MOUSEMOVE).

Okiedokie. Any ideas?? TIA
Nov 16 '05 #1
3 14121
You can use Control.Capture property to get mouse events that happen
outside your form.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
Jason wrote:
I'm trying to implement some pretty basic behavior in c#/.net 1.1
Forms but can't seem to find all the requisite pieces. When a user
clicks on the background of the form, I want the app to start
receiving MouseMove updates -- whether the pointer is over the form or
not (this being the crucial part) -- until the next MouseDown. It's
easy to receive MouseMove events while the pointer is over the form
but not when the pointer leaves. (Forms continue to receive
out-of-window MouseMove updates if a mouse-button is held down, ie a
drag, but not when just moving around.)

So, is there some simple way to do this in .NET?

The one approach that I've encounted which seems to have promise is
using the User32 SetCapture function. I can successfully capture the
mouse, but then I'm not sure how to receive the event messages
(specifically WM_MOUSEMOVE).

Okiedokie. Any ideas?? TIA

Nov 16 '05 #2
Well, actually, that only works when _dragging_ outside of the Form
(or control). So, for example, if the user presses a mouse button,
then drags outside the Form/Control while still holding the button,
said Form/Control receives MouseMove updates. However, even if the
Control.Capture is set to true, it won't receive general MouseMove
updates from outside the From... any ideas about how to do this?

Thanks!
Jason

Sijin Joseph <si***************@hotmail.com> wrote in message news:<OA**************@TK2MSFTNGP09.phx.gbl>...
You can use Control.Capture property to get mouse events that happen
outside your form.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Nov 16 '05 #3
Hi Jason,

Mouse capture won't help you with this. Mouse capture in windows works only
while mouse button is held down. Even windows form is designed in a way
where capture is released as soon as a mouse button is released. Otherwise
receiving mouse events from this point on is unreliable.

The only way to track the mouse if not button is pressed, IMHO, is to
install a windows hook. Fortunately WH_MOUSE_LL hooks can be programmed
with .NET.

The following is an article from MSDN Magazine obout writing windows hooks
in .NET

http://msdn.microsoft.com/msdnmag/is...0/CuttingEdge/

The autor (Dino Esposito) doesn't talk about mouse hooks but there are good
helper class for writing windows hooks.

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Jason" <ja***@mailinator.com> wrote in message
news:4a*************************@posting.google.co m...
I'm trying to implement some pretty basic behavior in c#/.net 1.1
Forms but can't seem to find all the requisite pieces. When a user
clicks on the background of the form, I want the app to start
receiving MouseMove updates -- whether the pointer is over the form or
not (this being the crucial part) -- until the next MouseDown. It's
easy to receive MouseMove events while the pointer is over the form
but not when the pointer leaves. (Forms continue to receive
out-of-window MouseMove updates if a mouse-button is held down, ie a
drag, but not when just moving around.)

So, is there some simple way to do this in .NET?

The one approach that I've encounted which seems to have promise is
using the User32 SetCapture function. I can successfully capture the
mouse, but then I'm not sure how to receive the event messages
(specifically WM_MOUSEMOVE).

Okiedokie. Any ideas?? TIA

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John Champaign | last post by:
Hi all, I'm working on an educational applet for a child with special needs. He's got a bit of a trick to make my life more difficult... To interact with the applet he needs to click on...
0
by: Stephen Williams | last post by:
I am migrating a VB 6 PictureBox control to VB.NET. In VB 6, this control modified its border style during the mouse down and up events to provide user feedback that it was selected. Once...
3
by: red | last post by:
mouse events when the mouse is on a "child control" hi everyone; my problem: I have a userControl in this usercontrol, I have a child control (a button) when the mouse moves over the...
2
by: KarenP | last post by:
In my Windows Forms application, while executing a process that takes some time, I am changing the cursor to the hourglass by setting Cursor.Current = Cursors.WaitCursor. This is working just...
6
by: Ahmed | last post by:
Hi, I am trying to capture the mouse events when the user clicks on the desktop not the winform. I looked at the mouse_event function but MSDN documentation says that it is suppressed in win...
0
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In...
5
by: Adeel | last post by:
Hi group! I'm trying to learn C# on my own... I'd appreciate it very much if someone can help me out here. I have a basic form without any controls on it... I want to catch mouse clicks (both...
2
by: ahmed.maryam | last post by:
Hello Everyone, I designed a custom control that is entirely covered by a picture box. I then dragged this custom control onto a windows form application (called main) and I need to handle mouse...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.