title: WPF: drawing own cursor - nontrivial problem
body: <p>i need to implement a cursor with some very specific features:</p>
  
  <ul>
  <li>it has to be animated
  
  <ul>
  <li>because after n seconds it automatically clicks - so the animation is feedback for the user when the click will happen</li>
  </ul></li>
  <li>it has to snap to some of our controls</li>
  <li>it has to work outside of our application</li>
  </ul>
  
  <p>the approaches so far:</p>
  
  <ul>
  <li>render my WPF-control into a bitmap, make a cursor-struct out of it and use user32.dll/SetSystemCursor to set it
  
  <ul>
  <li><strong>PRO</strong></li>
  <li>the cursor has no delay after the mouse since it's a real cursor</li>
  <li><strong>CON</strong></li>
  <li>snapping is quite hard, especially since we have absolute and relative inputdevices and i would have to reset the mouseposition all the time or use user32.dll/ClipCursor (System.Windows.Forms.Cursor.Clip does the same) but the snapped cursor is always shaking around the snapped position (tries to escape, get's reset again....)</li>
  <li>the code i use throws strange exceptions after some random time - so my current code seems quite unstable</li>
  </ul></li>
  <li>render my own cursor into a maximized, topmost, allowtransparent, windowstyle=none, invisible window and manually move the cursor after the mouse (like Canvas.SetLeft(cursor, MousePosition.X))
  
  <ul>
  <li><strong>PRO</strong></li>
  <li>snapping can be (easily) done</li>
  <li><strong>CON</strong></li>
  <li>when the mouse clicks and hit's the cursor the cursor get's clicked and not the window beyond</li>
  <li>polling the mouseposition in a dispatcher-background-loop all the time doesn't seem very beautiful to me</li>
  </ul></li>
  </ul>
  
  <p>to solve the second approach my cursor would have to have at least one transparent pixel
  in the hotspot, so that the mouse can click through... that doesn't seem like a real solution to me...</p>
  
  <p>any idea's anyone?</p>
  
  <p>EDIT:
  some example-source to show the problems...:</p>
  
  <p>example app &amp; source to show the problem with snapping the mouse to a fixed position: ClipIt.rar</p>
  
  <p>example app &amp; source that fails after random time - setting a self-drawn cursor: TryOwnCur.rar</p>
  
  <p>can be found under: <a href="http://sourcemonk.com/Cursor" rel="nofollow noreferrer">http://sourcemonk.com/Cursor</a></p>