Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

using the handpnt  curser in delphi 2

Posted on 1998-09-25
8
Medium Priority
?
165 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
[X]
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
  • 6
  • 2
8 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 210 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

688 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