Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

using the handpnt  curser in delphi 2

Posted on 1998-09-25
8
Medium Priority
?
170 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 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
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.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

927 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