代碼文件:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DXDraws, DXClass;
type
TForm1 = class(TForm)
DXDraw1: TDXDraw;
DXImageList1: TDXImageList;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{把 DXImageList1 的 DXDraw 屬性指定為 DXDraw1}
procedure TForm1.FormCreate(Sender: TObject);
begin
DXImageList1.DXDraw := DXDraw1; {這一步容易忽視; 也可以在設計時指定}
end;
{顯示列表中的第一個圖像}
procedure TForm1.Button1Click(Sender: TObject);
begin
{Draw 函數的參數 1 是繪圖表面}
{參數 2、3 是坐標}
{參數 4 用來指定使用第幾個調色板, 現在默認只有一個調色板, 只能是 0}
DXImageList1.Items[0].Draw(DXDraw1.Surface, 10, 10, 0);
DXDraw1.Flip;
end;
{顯示列表中的第二個圖像}
procedure TForm1.Button2Click(Sender: TObject);
begin
DXImageList1.Items[1].Draw(DXDraw1.Surface, 10, 10, 0);
DXDraw1.Flip;
end;
end.