程序中使用自定义的鼠标
一.建立工程与一个资源档
用Image Editor编辑一个鼠游标(Fild | New | Resource File)新建一个 CURSOR_1 的 CURSOR, 设定好它的 Hot Spot(Cursor | Set Hot Spot)存档时注意要和建立的Project存在同一个目录
在本例我们先假定为 MyCursor.res
二. 程序部分
定义一个常数crMyCursor, 这个常数您必须设成大於零 的任何整数, 以 LoadCursor() 函数将自订的鼠标资源
load 进来, 以下为源代码:
// unit.pas
unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes,
Graphics, Controls, Forms, Dialogs;
const
crMyCursor = 1; (* 宣告一个常数 *)
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
{$R mycursor.res}//这行$R不可少, 否则自订的鼠游标就出不来了
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
//将鼠标资源 load 进来
Screen.Cursors[crMyCursor] := LoadCursor (hInstance,'CURSOR_1');
Cursor := crMyCursor;//指定 form1 的 cursor 为自订鼠标
Button1.Cursor := crMyCursor;//指定Button1的cursor为自订鼠标
end;
end.
一.建立工程与一个资源档
用Image Editor编辑一个鼠游标(Fild | New | Resource File)新建一个 CURSOR_1 的 CURSOR, 设定好它的 Hot Spot(Cursor | Set Hot Spot)存档时注意要和建立的Project存在同一个目录
在本例我们先假定为 MyCursor.res
二. 程序部分
定义一个常数crMyCursor, 这个常数您必须设成大於零 的任何整数, 以 LoadCursor() 函数将自订的鼠标资源
load 进来, 以下为源代码:
// unit.pas
unit Unit1;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes,
Graphics, Controls, Forms, Dialogs;
const
crMyCursor = 1; (* 宣告一个常数 *)
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
{$R mycursor.res}//这行$R不可少, 否则自订的鼠游标就出不来了
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
//将鼠标资源 load 进来
Screen.Cursors[crMyCursor] := LoadCursor (hInstance,'CURSOR_1');
Cursor := crMyCursor;//指定 form1 的 cursor 为自订鼠标
Button1.Cursor := crMyCursor;//指定Button1的cursor为自订鼠标
end;
end.
解决方案 »
- 用corba做的一个helloworld程序,怎样放到广域网中运行(100分)?
- 如何捕获异常发出的单元名和触发该异常的方法名
- 散分,sql语句,谢谢
- 用Delphi开发的ActiveX Form,发布是以OCX形式,关于下载的问题
- 请问这样的字符串替换应该怎么做?谢谢。
- 简单问题:sockect如何传送整形、记录类型、等其它类型数据??
- 一个关于Access数据库的问题
- 征婚网址是:www.yichun-window.com(不许乱来了)
- How to get the exit code of TApplication.
- 如何得到当前windows的标题
- 千山一刀重出江湖!感谢站长、斑主和关心我的大侠们!
- x度空间,收分!
用{$R cur.cur}
把资源编译进EXE就行了嘛
但这样不太好,还是用Image Editor把Cursor弄到*.res中吧
但这样不太好,还是用Image Editor把Cursor弄到*.res中吧
http://www.csdn.net/expert/topic/378/378117.shtm