yingkit
asked on
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)
How can I change the mouse cursor globally. I know something like SetSystemCursor, LoadCursor should be used, but how?
Thanks.
(D2,Win95)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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)?
Delphi said that "OCR_NORMAL" is a undeclared identifier...
Should I include any unit(s)?
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.Cur sors[crHan dPoint], OCR_NORMAL);
end;
procedure TForm1.Button2Click(Sender : TObject);
begin
SetSystemCursor(Screen.Cur sors[crDef ault], 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;
,
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
begin
SetSystemCursor(Screen.Cur
end;
procedure TForm1.Button2Click(Sender
begin
SetSystemCursor(Screen.Cur
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;
Barry, how is this different from:
screen.cursor := crHandPoint; ?
Cheers,
Raymond.
screen.cursor := crHandPoint; ?
Cheers,
Raymond.
screen.cursor isnt global it only change the cursor while it on your app.
setsystemcursor change the cursor globally for all apps.
setsystemcursor change the cursor globally for all apps.
That would explain it!
Cheers,
Raymond.
Cheers,
Raymond.
ASKER
Barry's code works if I replace OCR_NORMAL with 32512
Perhaps this is because of my old Delphi 2.
Perhaps this is because of my old Delphi 2.
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.Cur sors[curs] ,OCR_NORMA L);
end;
i would use a const instead though ina small procedure like:
procedure mouseto(curs : string);
Const
OCR_NORMAL = 32512;
begin
SetSystemCursor(Screen.Cur
end;
ASKER