Get the cursor image

How to draw the current cursor onto an image.

I once wrote a component which reflected the cursor (looks nice). Obviously I

needed to know what the cursor looks like. There is a WinAPI command called

DrawIconEx which will draw an Icon when given the handle. To get the handle is

also easy, we look in the Screen.Cursors property. Like so :



var

  HCursor : THandle;

begin

  //Get the handle of the current cursor

  HCursor := Screen.Cursors[ Ord(Screen.Cursor) ];

  //Draw the icon to a canvas

  DrawIconEx( Form1.Canvas.Handle, XPos, YPos, HCursor, 32, 32, 0, 0, DI_NORMAL);

end;

 

 

Share this article!

Follow us!

Find more helpful articles: