Friday, March 26, 2010

Managed way to show Drag&Drop feedback image while dragging

Show translucent image under cursor while dragging data, inside own application or between applications, without using P/Invoke.

Implementation idea:
Using translucent top level Form that follows cursor while dragging

Test results:
Test is done only on Windows XP so i don't know if there is some unexpected different behavior on other platforms.

Using image with specified transparent color
[Cursor is in the middle, but isn't captured with Print Screen]

Using dynamically generated image
  • Show image with same level of translucency through pixels
  • Show image in shape other then rectangle by specifying color which is rendered transparent
  • Specify relative offset of cursor to image
  • Specify image opacity (greater opacity = lower translucency)
  • Can not render images with different alpha per pixel.
Source code:
You can get the source here.

No comments:

Post a Comment