Solved

using the handpnt  curser in delphi 2

Posted on 1998-09-25
8
157 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 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
Technology Partners: 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!

 

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

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…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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