Solved

Using a custom cursor with a RES file

Posted on 1998-10-21
7
168 Views
Last Modified: 2010-04-06
I have a customer cursor in a RES file.  The cursor is called CURSOR_1

If I am using Delphi 1, how do I assign this custom cursor to a TLabel, so that when the mouse is over the TLabel, the cursor will switch to the CURSOR_1 cursor?

In short, I am trying to create a fake URL link with a TLabel and Font style Underline.  The custom cursor is a  finger pointer cursor.

I understand that I must bind the RES file to my Main form...

implementation
{$R *.DFM}
{$R MYRESRC.RES}

...then what?
0
Comment
Question by:Kapusta
  • 3
  • 2
  • 2
7 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
ID: 1343837
Use the cursor property of the TLabel..

eg:

const
  MyCusorIdx = 1000;

MyLabel.Cursor := Screen.Cursors[MyCusorIdx];

You can add the cursor to screen.cursors like this:

Screen.Cursors[MyCusorIdx] := LoadCursor(HInstance, MakeIntResource(MyCusorIdx);

(Oh, this needs the cursor to be named as the cursor number, eg '1000' - this is how we do it, you could replace Makeintresource() with the name of your cursor 'CURSOR_1').

Cheers,

Raymond
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343838
It just struck me that you are making a component for a URL... There are also some freeware ones on the DSP

http://sunsite.icm.edu.pl/delphi/

Cheers,

Raymond.
0
 

Author Comment

by:Kapusta
ID: 1343839
I have done what you said, and it does not work.  I have renamed my cursor in my RES file from 'CURSOR_1' to '1000'

procedure TForm1.FormCreate(Sender: TObject);
begin
Screen.Cursors[1000] := LoadCursor(HInstance, '1000');
Label1.Cursor := Screen.Cursors[1000];

I have then performed a "Build All", and recompiled, and yet when the mouse is over top of the Label1 component at run time, the custom cursor is NOT displayed.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 10

Expert Comment

by:viktornet
ID: 1343840
Hello guys,....

Try this one...

{$R Whatever.res}

const
  crMyCur = 1;

procedure TForm1.WhateverFormCreate(Sender : TObject);
begin
  Screen.Cursors[crMyCur] := LoadCursor(HInstance, 'CURSOR_1');
  Label1.Cursor := crMyCur;
end;

Hope this helps.....

Cheers,
Viktor
0
 

Author Comment

by:Kapusta
ID: 1343841
Thanks Victornet...your clarification fixed the problem.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1343842
Any time ;->

Cheers,
Viktor
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343843
I really have to start compiling the code I write, sigh :-(

0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 90
Delphi Firemonkey Need Sample for Online Shopping Example. 2 142
Run video youtube webbrowse 10 62
DBCtrlGrid, Delphi, Scroll 7 14
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

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