?
Solved

using SetSystemCursor properly.

Posted on 2005-03-28
9
Medium Priority
?
245 Views
Last Modified: 2010-04-04
I am still alil mystified as the the proper way to use the SetSystemCursor function and was hoping  one of the experts here could provide me with alil code on how to use it properly...

Basically all I want to do is to click on this little icon I placed in a panel on my program and as long as I keep the mouse button down (even when moving it off my application) the system cursor will change to that icon and when I let go of the mouse button it will change back to the normal system cursor.

I hope I explained my needs well enough but if not then I will try to help anyway I can and thank you for your replies in advance.
0
Comment
Question by:voodoo22
[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
  • 3
9 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13650864
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Screen.Cursor := crHourGlass;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Screen.Cursor := crDefault;
end;

seemed to work fine for me
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13651074
This will change your cursor to an hourglass. It will stay like that as long as you dont let go of the mouse button.
It seems to work even if not on the application but let me know please.
0
 

Author Comment

by:voodoo22
ID: 13651765
that  only seems to work for the cursors that are built into delphi but I need it to work when I load a custom cursor from a resource file.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13652037
These PAQ's should tell you how to load your cursor from a file
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10019363.html?query=load+cursor+from+file&topics=85
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20685409.html?query=load+cursor+from+file&topics=85


the interesting bits are:
1. By the Image Editor which comes with Delphi, create a new resource file on the same directory of the project. Name it as test.res.
2. Draw a cursor and name it as CURSOR_1.

screen.cursors[1]:=LoadCursor(hInstance, pChar('CURSOR_1'));
0
 

Author Comment

by:voodoo22
ID: 13652471
tried that no joy.... what happens is when I click on image1 nothing happens but when I let off the mouse the custom cursor loads and no matter what I do it will not go away when it's over my application but as soon as I leave my app it goes back to the normal cursor again which is obviously not what I am wanting to do.

Code:

Const
crMyCursor = 1;

var
  Form1: TForm1;

implementation

{$R *.dfm}
{$R crf.RES}

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Screen.Cursors[crMyCursor] := LoadCursor(HInstance, 'search_cursor');
  Cursor := crMyCursor;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 Screen.Cursor := crDefault;
end;

end.


Again all I want to do is when I put click and hold down the mouse button it will load my custom cursor and when I let off the mouse button it will go back to the normal cursor. Sounds ez but so far it's been everything but.
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13653034
Try changing to

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Screen.Cursors[crMyCursor] := LoadCursor(HInstance, 'search_cursor');
  Screen.Cursor := crMyCursor;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Screen.Cursor := crDefault;
end;
0
 
LVL 15

Accepted Solution

by:
mikelittlewood earned 500 total points
ID: 13653046
I think Cursor := crMyCursor was the issue.
Should be Screen.Cursor := crMyCursor
0
 

Author Comment

by:voodoo22
ID: 13653552
that did the trick thx for the help.
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13659668
Glad I could poiint you in the right direction
0

Featured Post

Independent Software Vendors: 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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 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