Chinaunix首页 | 论坛 | 博客
  • 博客访问: 14481198
  • 博文数量: 5645
  • 博客积分: 9880
  • 博客等级: 中将
  • 技术积分: 68081
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-28 13:35
文章分类

全部博文(5645)

文章存档

2008年(5645)

我的朋友

分类:

2008-04-28 20:47:10

下载本文示例代码
  在Delphi中用Loadcursor()得到的光标只有黑白两色,怎样在程序中得到彩色光标呢?笔者尝试制作了以下程序:   方法一 用Loadcursorfromfile()从外部调入图标作为光标   Loadcursorfromfile()函数可以读*?CUR,*?ICO,*?ANI为后缀的文件作为光标,其中ICO为彩色图标格式(可用Image Editor制作),ANI为动画光标格式。以下为打开一图标作为光标的演示程序段,当光标移动到测试区域内光标会变成选定的图案;   {设:opendialog1:Topendialog;Bitbtn1:Tbitbtn}   procedure TForm1.BitBtn1Click(Sender:TObject);   var tt:pchar;size:integer;s:string;   begin   if opendialog1.Execute then   begin   size:=length(opendialog1.filename);   getmem(tt,size);   s:=opendialog1.filename;   strpcopy(tt,s);   screen.cursors[2]:=loadcursorfromfile(tt);   bf.cursor:=2;   freemem(tt,size);   end;   end;   方法二 从资源文件加载彩色光标   用方法一发送程序时必须包含*?CUR文件,因而从资源文件中加载彩色光标是更可行的方法。   用图标存放彩色光标,使用时把图标存入临时文件,用Loadcursorfromfile()从临时文件读出彩色光标。   程序段:   procedure ZloadfromResourse(screenindex:integer;name:Pchar);   var td:ticon;   begin   try   td:=ticon.Create;   td.Handle:=LoadIcon(Hinstance,name);   td.SaveToFile(′temp.cur′);   screen.Cursors[screenindex]:=loadcursorfromfile(′temp.cur′);   deletefile(′temp.cur′);   finally   td.free;   end;   end;   此程序把名字为name的图标变为序号为screenindex的光标;   例:   ZloadfromResourse(2,′myicon′);   Form1.cursor:=2;   注意:′myicon′这个图标一定要在资源文件中,否则会出现异常。   在Delphi中用Loadcursor()得到的光标只有黑白两色,怎样在程序中得到彩色光标呢?笔者尝试制作了以下程序:   方法一 用Loadcursorfromfile()从外部调入图标作为光标   Loadcursorfromfile()函数可以读*?CUR,*?ICO,*?ANI为后缀的文件作为光标,其中ICO为彩色图标格式(可用Image Editor制作),ANI为动画光标格式。以下为打开一图标作为光标的演示程序段,当光标移动到测试区域内光标会变成选定的图案;   {设:opendialog1:Topendialog;Bitbtn1:Tbitbtn}   procedure TForm1.BitBtn1Click(Sender:TObject);   var tt:pchar;size:integer;s:string;   begin   if opendialog1.Execute then   begin   size:=length(opendialog1.filename);   getmem(tt,size);   s:=opendialog1.filename;   strpcopy(tt,s);   screen.cursors[2]:=loadcursorfromfile(tt);   bf.cursor:=2;   freemem(tt,size);   end;   end;   方法二 从资源文件加载彩色光标   用方法一发送程序时必须包含*?CUR文件,因而从资源文件中加载彩色光标是更可行的方法。   用图标存放彩色光标,使用时把图标存入临时文件,用Loadcursorfromfile()从临时文件读出彩色光标。   程序段:   procedure ZloadfromResourse(screenindex:integer;name:Pchar);   var td:ticon;   begin   try   td:=ticon.Create;   td.Handle:=LoadIcon(Hinstance,name);   td.SaveToFile(′temp.cur′);   screen.Cursors[screenindex]:=loadcursorfromfile(′temp.cur′);   deletefile(′temp.cur′);   finally   td.free;   end;   end;   此程序把名字为name的图标变为序号为screenindex的光标;   例:   ZloadfromResourse(2,′myicon′);   Form1.cursor:=2;   注意:′myicon′这个图标一定要在资源文件中,否则会出现异常。 下载本文示例代码


让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中让彩色光标出现在Delphi程序中
阅读(139) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~