Change the cursor globally.

Hello,
How can I change the mouse cursor globally.  I know something like SetSystemCursor, LoadCursor should be used, but how?
Thanks.
(D2,Win95)
yingkitAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

yingkitAuthor Commented:
Edited text of question.
0
intheCommented:

     SetSystemCursor(Screen.Cursors[crHandPoint], OCR_NORMAL);

then back to normal :

     SetSystemCursor(Screen.Cursors[crDefault], OCR_NORMAL);

Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yingkitAuthor Commented:
I 've tried this before but I can't compile it successfully.
Delphi said that "OCR_NORMAL" is a undeclared identifier...
Should I include any unit(s)?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

intheCommented:
no it should work straight away its iin windows.pas(or what version of delphi you have?
,
here is what i did from new project:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
 SetSystemCursor(Screen.Cursors[crHandPoint], OCR_NORMAL);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 SetSystemCursor(Screen.Cursors[crDefault], OCR_NORMAL);
end;

end.

the following consts are defined in windows.pas:


OCR_NORMAL              = 32512;
  {$EXTERNALSYM OCR_IBEAM}
  OCR_IBEAM               = 32513;
  {$EXTERNALSYM OCR_WAIT}
  OCR_WAIT                = 32514;
  {$EXTERNALSYM OCR_CROSS}
  OCR_CROSS               = 32515;
  {$EXTERNALSYM OCR_UP}
  OCR_UP                  = 32516;
  {$EXTERNALSYM OCR_SIZE}
  OCR_SIZE                = 32640;  { OBSOLETE: use OCR_SIZEALL }
  {$EXTERNALSYM OCR_ICON}
  OCR_ICON                = 32641;  { OBSOLETE: use OCR_NORMAL }
  {$EXTERNALSYM OCR_SIZENWSE}
  OCR_SIZENWSE            = 32642;
  {$EXTERNALSYM OCR_SIZENESW}
  OCR_SIZENESW            = 32643;
  {$EXTERNALSYM OCR_SIZEWE}
  OCR_SIZEWE              = 32644;
  {$EXTERNALSYM OCR_SIZENS}
  OCR_SIZENS              = 32645;
  {$EXTERNALSYM OCR_SIZEALL}
  OCR_SIZEALL             = 32646;
  {$EXTERNALSYM OCR_ICOCUR}
  OCR_ICOCUR              = 32647;  { OBSOLETE: use OIC_WINLOGO }
  {$EXTERNALSYM OCR_NO}
  OCR_NO                  = 32648;
  {$EXTERNALSYM OCR_HAND}
  OCR_HAND                  = 32649;
  {$EXTERNALSYM OCR_APPSTARTING}
  OCR_APPSTARTING         = 32650;

0
rwilson032697Commented:
Barry, how is this different from:

screen.cursor := crHandPoint; ?

Cheers,

Raymond.
0
intheCommented:
screen.cursor isnt global it only change the cursor while it on your app.
setsystemcursor change the cursor globally for all apps.
0
rwilson032697Commented:
That would explain it!

Cheers,

Raymond.
0
yingkitAuthor Commented:
Barry's code works if I replace OCR_NORMAL with 32512
Perhaps this is because of my old Delphi 2.
0
intheCommented:
well done you got it :-)

i would use a const instead though ina small procedure like:

procedure mouseto(curs : string);
Const
 OCR_NORMAL = 32512;
begin
SetSystemCursor(Screen.Cursors[curs],OCR_NORMAL);
end;

   
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.