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?
 
intheConnect With a Mentor Commented:

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

then back to normal :

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

Regards Barry
0
 
yingkitAuthor Commented:
Edited text of question.
0
 
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
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
All Courses

From novice to tech pro — start learning today.