怎么为自己的控件写些资源,然后又怎么把它包含到工程里去?

解决方案 »

  1.   

    //这是我写的一段加载自定义光标的方法
    var 
       Form1: TForm1; 
      implementation 
      {$R *.DFM} 
      {$R my.res}//加载资源文件my.res 
      procedure TForm1.FormCreate(Sender: TObject); 
      const 
      crmy1=1; 
      crmy2=2; 
      crmy3=3; 
      var 
      result1,result2,result3:integer; 
      begin 
       result1:=loadcursorfromfile(′my.cur′); 
       if result1<>0 then //如果返回值为0,则调用失败! 
       screen.cursors[crmy1]:=result1 
       else 
       showmessage(′加载静态光标文件出错!′); 
       result2:=loadcursorfromfile(′my.ani′); 
       if result2<>0 then 
       screen.cursors[crmy2]:=result2 
       else 
       showmessage(′加载动态光标文件错误!′); 
       result3:=loadcursor(Hinstance,′mycursor′); 
      Hinstance为定义在System单元中的一个长整变量,其值为应用程序的句柄,由Delphi自己维护。 
      在加载资源文件的光标资源时,如果光标的名字为整数(Vc++的资源编辑器给资源的缺省名就为整数),就必须使用API函数Makeintresource将整数转换为PansiChar类型,再传递给Loadcursor函数。 
      例如:result:=Loadcursor(Hinstance,Makeintresource(101))} 
       if result3<>0 then 
       screen.cursors[crmy3]:=result3 
       else 
       showmessage(′加载资源文件中的光标资源出错!′); 
      //使用加载的光标,cursors[]数组为全局变量,可在程序的任何地方调用; 
       if result1<>0 then 
       screen.cursor:=crmy1; 
       if result2<>0 then 
       form1.cursor:=crmy2; 
       if result3<>0 then 
       screen.cursor:=crmy3; 
      end; 
      end.