Solved

Using a custom cursor with a RES file

Posted on 1998-10-21
7
170 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
When I am typing into a TEdit last word repeats 7 145
Help on project with Soap 10 57
Run video youtube webbrowse 10 65
How to insert .png images to TClientDataSet .cds file? 2 31
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

840 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