tags:

views:

117

answers:

1

I'm trying to override the cursor for the entire computer this.Cursor = Cursors.Pen; System.Windows.Input.Mouse.OverrideCursor = Cursors.Pen;

This works within the WPF "Window", but not anywhere outside it.

What .dll will let me do this?

+6  A: 

This behavior is by design, and a good thing.

Look at the native routines, such as SetCursor, and you'll see this:

The cursor is a shared resource. A window should set the cursor shape only when the cursor is in its client area or when the window is capturing mouse input. In systems without a mouse, the window should restore the previous cursor before the cursor leaves the client area or before it relinquishes control to another window.

You shouldn't try to override the cursor for other applications. Doing so is being a bad citizen on the system. As long as your application is active, or you have a window capture mouse input, then the cursor you set via Mouse.OverrideCursor will remain active.


Given that you really don't care about playing nice, though, you can always just go all-out and make your program take over the system. Just run your main window as a full screen application, with a window over each monitor on the system, and set them all to Topmost. Set your cursor, and the mouse will never leave the window.

While you're at it, you should consider downloading a bunch of these nice unicorn images from the StackOverflow Users page, and tile the background of the windows with them. This would really add a nice, subtle effect to the user's desktop.

Reed Copsey
I'm trying to be a bad citizen though, I'm Jeffery Freakin Dahmer ;)
Jeff Dahmer
@Jeff: While, in that case - see my edit ;)
Reed Copsey