Solved

Screen.Cursor help

Posted on 2004-09-09
8
207 Views
Last Modified: 2010-04-04
I've got a hyperlink (a Label that has been altered anyway) on my form and I'd like to change the cursor to one representing the cursor that the user has specified for links. However this 'Link Cursor' was only able to be set in windows xp as far as I know. In Delphi6/7 I see no references to any other cursors except the standard 0 to -22 ones. I've tried going out of that range with no luck. Has anyone else been able to get the hyperlink cursor to display?
0
Comment
Question by:Narusegawa
8 Comments
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12016270
Yes. Include the cursor you like in your *.res file, load it when your application starts and use that cursor when you're above the link. Unfortunately I don't have Delphi easily available right now so perhaps someone else can show you how...
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 25 total points
ID: 12016313
What do you mean with 'Link Cursor' ?
I've always saw a crHandPoint as Hyperlink Cursor....

BTW you can load a custom cursor easly when you want...

The easiest example from Delphi Help:

This example shows how to add custom cursors to an application.  It assumes that a custom cursor with the name NewCursor has been added to the resources (.RES file) of the application. You can add the cursor using the image editor. (Tools | Image Editor)
The following code makes this cursor available to the application via the constant crMyCursor, and sets it as the global cursor to the application.

const

  crMyCursor = 5;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Screen.Cursors[crMyCursor] := LoadCursor(HInstance, 'NewCursor');
  Cursor := crMyCursor;
end;
0
 

Author Comment

by:Narusegawa
ID: 12016346
I want the user to display whatever he or she has set for their hyperlink cursor. Not what I put in the .res file as that beats the object of it. There must be a way of getting it someone, it's a system cursor. It's just not in the list that comes with Delphi and on most webpages.  It's none of the below:

Arrow, Cross, IBeam, UpArrow, Drag, NoDrop, HSplit, VSplit, MultiDrag, SQLWait, No, AppStart, Help, HandPoint or the Size and different Size pointers (SizeAll, SizeNESW, SizeNS, SizeNWSE, SizeWE).

In Windows XP, if you check the 'Pointers' tab you see the list of cursors. At the bottom, after "Alternate Select" is one called "Link Select".
0
 

Author Comment

by:Narusegawa
ID: 12016390
I've used crHandPoint already and that displays the white hand, however in Windows XP which is what I am using I set a different cursor for that for all programs like IE/Mozilla etc etc.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Narusegawa
ID: 12016520
If I look into HKEY_CURRENT_USER/Control Panel/Cursors and check the value for 'Hand' I see the cursor I chose. Not sure why crHandPoint doesn't use this cursor file though.

Is there a quick way to instead get this registry value if it exists into a variable like Ferrucio said above?

This is my own personal thought on how to get around this problem.
0
 

Author Comment

by:Narusegawa
ID: 12016663
I'm now trying the following but it doesn't come up with anything. The value in CursorPath is : %USERPROFILE%\My Documents\My Themes\Cursors\Premium 1.5\Premium_link.cur : and the file does exist.

const
  crLinkSelect = 5;

procedure TfrmSplash.FormCreate(Sender: TObject);
var
  CursorPath: string;
begin
  CursorPath := GetRegistryData(HKEY_CURRENT_USER,'\Control Panel\Cursors','Hand');
  Screen.Cursors[crLinkSelect] := LoadCursor(HInstance, PChar(CursorPath));
end;

procedure TfrmSplash.lblURLMouseEnter(Sender: TObject);
begin
  FURLColor := lblURL.Font.Color;
  lblURL.Font.Color := $00DD0000;
  Screen.Cursor := crLinkSelect;
end;
0
 
LVL 17

Assisted Solution

by:geobul
geobul earned 25 total points
ID: 12017686
Hi,

Use LoadCursorFromFile API instead of LoadCursor.

Regards, Geo
0
 

Author Comment

by:Narusegawa
ID: 12017769
Thanks, I have it working with LoadCursorFromFile, I just need to now figure out this other API thing at http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21124755.html to finish this off.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now