Solved

using the handpnt  curser in delphi 2

Posted on 1998-09-25
8
141 Views
Last Modified: 2010-04-06
I would like to use the handpnt curser that is in the curser folder in delphi 2,How can I get the curser to change
from the standard pointer to the hand curser when it is above a button.It does not appear in the list of cursers in the object inspector.
0
Comment
Question by:alix
  • 6
  • 2
8 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 70 total points
Comment Utility
You need to save the cursor file in a resource file and then use the LoadCursor(hInstance, 'NameOfCursorFromTheResourceFile'); function to load the cursor...

regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Here are two ways to do that...

1) Use the resource file...
const
  crMyCursor = 1;
procedure TForm1.FormCreate(Sender: TObject);
begin
   Screen.Cursors[crMyCursor] := LoadCursor(hInstance, 'MYCUR');
   Cursor := crMyCursor;
end;

2) Using the File.cur but you need to include the CUR file with your app...otherwise it won't work

const crMyCursor = 1;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Screen.Cursors[crMyCursor] := LoadCursorFromFile('c:\mystuff\mycursor.cur');
  Cursor := crMyCursor;
end;

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Does this help alix???

/Viktor Ivanov
0
 

Author Comment

by:alix
Comment Utility
Thank you viktor i used the second option as i did not uderstand
how to do the first option.It has not fully done what i had  hoped for,I would like the hand curser to appear only when the pointer curser is above a label or button is that possible,my software is for children and i need them aware as to when they can click something..

regards..alix
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 10

Expert Comment

by:viktornet
Comment Utility
There is a cursor that is called crHandPoint that is the exact as the one from the directory...

Here is what I just thought of something that does exactly what you want... Follow the steps..

1) Select all the controls that you want to change the cursor on
  To select all just drag the rectangle to cover all of those controls....or just select them one by one by holding down the Shift key and then selecting the controls one by one,,,

2) Go to the properties and turn to the Events page of the Object Inspector...
3)Find the property OnMouseMove and double click in that place so it shows you the OnMouseMove of all controls....It would look something like this....

procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin

end;
4) enter this code into the event so it would look like this...

procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  TControl(Sender).Cursor := crHandPoint;//you can replace the crHandPoint to your cursor
end;

If you don't understand something ask or ask me to send you an example app.....

Regards,
Viktor Ivanov
0
 

Author Comment

by:alix
Comment Utility
Hello viktor,all of your advice work with the standard cursors
that are listed in the object inspetor,but in delphi 2 there is a sub directory that contains extra cursors, the one I want to use is "handpnt.cur" I have put a copy of that cursor in my application directory and also tried adding"LoadCursorFromFile"
to your examples with no joy...any further ideas...

This is what I have tried last....

procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  TControl(Sender).Cursor := LoadCursorFromFile('C:\Alix Project\crHandpnt');
end;

Regards Alix..

0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
const
  crMyCursor = 1;

procedure TForm1.FormCreate(Sender: TObject);
begin
    Screen.Cursors[crMyCursor] :=  LoadCursorFromFile('c:\mystuff\mycursor.cur');
   Cursor := crMyCursor;
end;

procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState;X,Y: Integer);
begin
     TControl(Sender).Cursor := crMyCursor;
end;

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Actually this is the real code...sorry,,,,,


       crMyCursor = 1;

     procedure TForm1.FormCreate(Sender: TObject);
     begin
         Screen.Cursors[crMyCursor] :=  LoadCursorFromFile('c:\mystuff\mycursor.cur');
     end;

     procedure TForm1.Button1MouseMove(Sender: TObject; Shift:
     TShiftState;X,Y: Integer);
     begin
          TControl(Sender).Cursor := crMyCursor;
     end;
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

771 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

11 Experts available now in Live!

Get 1:1 Help Now