Fog Creek Software
Discussion Board




RegisterRawInputDevices help needed

How can I register  for raw input and receive WM_INPUT messages on a background window?

I filled out the appropriate field in RAWINPUTDEVICE (mouse[0].hwndTarget = this->m_hWnd;) before registration. The window receives WM_INPUT messages when in focus but not in background.

Google search did not give any useful information on this topic.

Your help is appreciated.

Code Monkey
Sunday, July 04, 2004

If a window is in the background, it does not receive WM_INPUT messages. You have to use DirectInput and set to exclusive mode.

Mr. O
Sunday, July 04, 2004

Microsoft states: "An application can receive data when it is in the foreground and when it is in the background."

Code Monkey
Sunday, July 04, 2004

Forgot to add the link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/RawInput/AboutRawInput.asp

Code Monkey
Sunday, July 04, 2004

And your dwFlags include RIDEV_INPUTSINK?

.
Sunday, July 04, 2004

Applications may receive non-user interface input related data while in the background.  A mouse run through it's windows driver does not qualify as non-user interface input but a process or thread running in the background receiving data from a serial port, for instance, would work.

If you really need mouse data sent to a background window you may need to obtain that data via the ps/2 or serial port (if could even do that).  Windows thinks the mouse is being used on the active window and doesn't send messages to background windows save perhaps the desktop window.

It makes sense if you think about two 'pencil drawing' applications' each with their own window overlapped on the desktop.  Dragging the mouse inside the foreground window leaves a line where the mouse has been dragged.  Now if the user were to drag outside the first window over the background window you wouldn't expect the pen to continue drawing.  Instead you want to activate the background window with a click thus telling windows to send messages to to it.

I may be totally off on this, but it's the best explaination I can come up with.

Dave B.
Sunday, July 04, 2004

nm.. the INPUTSINK flag would seem to do the trick.

Dave B.
Sunday, July 04, 2004

I'm sure you're aware that this is only available on XP and .NET server.

Blank
Sunday, July 04, 2004

So how does that work anyway?

During the background applications' time slice windows simply sends the data to the application via the WM_INPUT message even though it doesn't have the focus?  It seems you could do some pretty crazy stuff like that.

Dave B.
Sunday, July 04, 2004

Thank you guys. RIDEV_INPUTSINK did the trick.

As a side effect I realized again how useful this forum is.

Code Monkey
Sunday, July 04, 2004

*  Recent Topics

*  Fog Creek Home