![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
Valued Member
Join Date: Jan 2004
Location: England
Posts: 265
|
Hi guys
Is it possible for a window to recive mouse move messages when the mouse pointer is outside the client area? I know about WM_NCMOUSEMOVE, but that doesnt solve the problem of detecting movement when the cursor is totally out of the area of the window. SetCapture only seems to work if the left mouse button is down, but this isnt good enough for what I'm after. It needs to detect it regardless of the mouse state Thanks Spree |
|
|
|
|
|
#2 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
i tihnk you have the option to either totally direct all input to the window, then you will get mouse movements even if the position is beyond the window boundaries. or you share the input. in the second case you have no way to catch the input. i might be wrong though...
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#3 |
|
DevMaster Staff
Join Date: Jan 2003
Posts: 1,201
|
Have you tried out the TrackMouseEvent function? You can call it to tell it to send the WM_MOUSELEAVE message when the mouse leaves your window. Also, the function GetCursorPos() gives you the mouse's position regardless of the which app has the focus. You can easily use it to make your own mouse-move detection scheme.
|
|
|
|
|
|
#4 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
oh, i only thought about directx
![]() normally you onyl direct messages to your window that are meant for it. however you can peek the windows message stack at any time. this will allow you to intercept any mouse movement, even outside of your window
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#5 |
|
New Member
Join Date: Jul 2004
Posts: 1
|
This below code does the trick.
Also, on a related note... When a user holds down the mouse button (WM_LBUTTONDOWN), then drags the mouse out of the window and lets the mouse button up, you don't get the WM_LBUTTONUP message unless you use SetCapture() and ReleaseCapture() in your OnLButtonDown() and OnLButtonUp() functions respectively. Code to detect the mouse leaving your window follows: 1. Add a timer UINT to your view class: Code:
2. Initialise the timer UINT in your constructor: Code:
3. When the mouse is initally in your window, start the timer: Code:
4. In OnTimer, detect if the mouse has left your window and post a message: Code:
5. Add a OnMouseLeave(..) handler: (i) In your afx message map, in the .h file: Code:
(ii) In your message map: Code:
(iii) OnMouseLeave Function Code:
.... and that, is that. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|