unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Timer1: TTimer; {需要个定时器}
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
  
procedure TForm1.FormCreate(Sender: TObject);
//把系统提供的 Cursor 全部加入到 Screen.Cursors 
var
  i: Integer;
begin
  for i := 0 to 22 do
  begin
    Screen.Cursors[i] := TCursor(-i); 
  end;

  {同时设定 Timer1 没 1/4 秒执行一次}
  Timer1.Interval := 250;

{但是很奇怪, 这时的 Screen.CursorCount 竟然是 0? 糊涂了}
end;


procedure TForm1.Timer1Timer(Sender: TObject);
//让窗体的光标随机更换
begin
  Self.Cursor := Screen.Cursors[Random(22)];
end;

end.

//后来的补充 - 如果仅仅要这个效果, 这样就够了: procedure TForm1.FormCreate(Sender: TObject); begin Timer1.Interval := 250; {设定 Timer1 没 1/4 秒执行一次} end; //让窗体的光标随机更换 procedure TForm1.Timer1Timer(Sender: TObject); begin Self.Cursor := TCursor(-Random(22)); end;
posted on 2008-01-22 16:02  万一  阅读(3657)  评论(3编辑  收藏  举报