472,789 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 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 14080
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.