Recent

Author Topic: Cursor Image  (Read 5555 times)

march

  • New Member
  • *
  • Posts: 17
Cursor Image
« on: February 08, 2011, 09:42:55 am »
How do I get the image of a current standard cursor, like crArrow? The icon must be stored somewhere. I would like to be able to draw it on a canvas or add it to a bitmap, etc.

ringo

  • New Member
  • *
  • Posts: 16
Re: Cursor Image
« Reply #1 on: February 08, 2011, 09:51:03 am »
I'll make the assumption that you are running Windows.

Take a look in C:\WINDOWS\Cursors (or your install equivalent) to find the graphics of all the normal cursors.  They are files called xxx.CUR.  A CUR file is a 2-color transparent icon, and can be opened by most Windows-base graphics editor.

Ringo

march

  • New Member
  • *
  • Posts: 17
Re: Cursor Image
« Reply #2 on: February 08, 2011, 08:26:36 pm »
I do happen to be using Lazarus under Win XP, but my application needs access to the current cursor image, in real time, in a way that is independent of the operating system. An instant cursor change can be coded by simply invoking a new constant. I expect there must be a connection to the image available through a Lazarus or FPC library.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8267
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Cursor Image
« Reply #3 on: February 09, 2011, 05:57:04 am »
Quote
but my application needs access to the current cursor image, in real time, in a way that is independent of the operating system
Hmm... Screen.Cursors ?

march

  • New Member
  • *
  • Posts: 17
Re: Cursor Image
« Reply #4 on: February 10, 2011, 07:02:05 am »
Screen.Cursors are type hCursor. I do not really know how to derive an image from that, but after much deliberation, gave it a try anyhow. This compiled and ran but produced no result on a blank area of the form. Something is missing or it may be completely wrong.

Lazarus 0.9.28.2, FPC 2.2.4, WinXP

Code: Pascal  [Select][+][-]
  1. procedure tFormMain.DrawMainCanvas(Sender: tObject);
  2. var
  3.  TheCursorImage  : tCursorImage;
  4.  
  5. begin
  6.  ...
  7.  TheCursorImage := tCursorImage.Create;      
  8.  TheCursorImage.Handle := screen.cursors[screen.cursor];
  9.  Canvas.Draw(700,200,TheCursorImage);
  10.  TheCursorImage.Free;
  11.  ...
  12.  

 

TinyPortal © 2005-2018