Solved

Screen mouse cursor shape?

Posted on 2004-04-24
6
1,236 Views
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?

Brimountain
0
Comment
Question by:brimountain
  • 4
6 Comments
 
LVL 11

Expert Comment

by:shaneholmes
Comment Utility
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

Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
Comment Utility
0
 
LVL 11

Expert Comment

by:shaneholmes
Comment Utility
Sorry, I almost forgot, you need to declare two constants as well

Const
 crC1=1;
 crC2=2



Shane
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 3

Expert Comment

by:Kunfufaresi
Comment Utility
Hello

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

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

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

Kunfu Faresi
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 50 total points
Comment Utility
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.

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

Shane
0
 

Author Comment

by:brimountain
Comment Utility
Thank you so much, but i am pretty busy nowadays. I'll try your comments when free and get back soon.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now