Link to home
Start Free TrialLog in
Avatar of Narusegawa
Narusegawa

asked on

Screen.Cursor help

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?
Avatar of Wim ten Brink
Wim ten Brink
Flag of Netherlands image

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...
ASKER CERTIFIED SOLUTION
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Narusegawa
Narusegawa

ASKER

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".
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.
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.
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;
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, I have it working with LoadCursorFromFile, I just need to now figure out this other API thing at https://www.experts-exchange.com/questions/21124755/ExpandEnvironmentStringsForUser.html to finish this off.