<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      讓彩色光標出現在Delphi程序中

      [摘要]在Delphi中用Loadcursor()得到的光標只有黑白兩色,怎樣在程序中得到彩色光標呢?筆者嘗試制作了以下程序:   方法一 用Loadcursorfromfile()從外部調入圖標作為光標 ...
      在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′這個圖標一定要在資源文件中,否則會出現異常。


      日韩精品一区二区三区高清