Solved

using the handpnt  curser in delphi 2

Posted on 1998-09-25
8
148 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
ID: 1340858
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
ID: 1340859
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
ID: 1340860
Does this help alix???

/Viktor Ivanov
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 

Author Comment

by:alix
ID: 1340861
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1340862
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
ID: 1340863
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
ID: 1340864
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
ID: 1340865
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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