Screen mouse cursor shape?

Posted on 2004-04-24
Medium Priority
Last Modified: 2008-02-01
Delphi has about 22 vailable screen cursor shapes (TCursor) : CrArrow, CrHourGlass...etc.  However, the shape I want (a pen icon) is not there.

How can I change my mouse cursor to a pen icon in run time?

Can I install some new cursor shapes to Delphi? If yes, how to do this?

Question by:brimountain
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
LVL 11

Expert Comment

ID: 10910284
Use Image Editor to cteate a new resource file with the new cursors you want.

then add the following directive

 {$R Cursors.RES}

- on forms created event i added

         Screen.Cursors[crC1]   := LoadCursor(hInstance,  'C1');
         Screen.Cursors[crC2]   := LoadCursor(hInstance,  'C2');

- and when you need new cursor just set      

          Screen.Cursor := crC1;

An important consideration when you customize a cursor is where to put the hot spot (the cursor's active area). The hot spot is the single pixel in the cursor that fixes the location when the user places the cursor and clicks to make a selection.

To set hot spots: (in image editor)

1.     Use the View|Zoom In command to zoom in on the cursor image until it's big enough to let you precisely choose the pixel coordinates for the hot spot.
2.     Display a grid on the zoomed image.
3.     Select the Line tool.
4.     Point to the location on the zoomed image where you want the hot spot and look at the coordinates displayed on the right side of the status line. Make a note of these coordinates.
5.     Choose Cursor |Set Hot Spot.
6.     Enter the hot spot's pixel coordinates and click OK.

Hope this helps

LVL 11

Expert Comment

ID: 10910310
Sorry, I almost forgot, you need to declare two constants as well


What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 10911156

After Shane, what is there left to say :) just a way i used to do it differs a little

 newcur : TCursor;
 NewCur := LoadCursorFromFile('test.cur');
 Screen.Cursor := NewCur;

of course putting the cur into the resource and you can use LoadCursor to get it.

Kunfu Faresi
LVL 11

Accepted Solution

shaneholmes earned 200 total points
ID: 10912074
Yup thats a good method as well, only you have to distribute the cursor with your executable,

and you have to make sure you test for the cursor file each time as well, and if it doesn't exist then revert back to default cursor.

 newcur : TCursor;
 if fileExists('test.cur') then
  NewCur := LoadCursorFromFile('test.cur');
  Screen.Cursor := NewCur;
 Screen.Cursor:= crDefault;


Author Comment

ID: 10917566
Thank you so much, but i am pretty busy nowadays. I'll try your comments when free and get back soon.

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question