程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> 紙牌控件的編寫(中)

紙牌控件的編寫(中)

編輯:Delphi

function cdtInit(var CardWidth, CardHeight: TCoordinate): Bool; {$ifdef<?XML:namespace prefix = o ns = "urn:schemas-microsoft-com:office:Office" />

Win32}stdcall;

{$ENDIF Win32}

function cdtDraw(aDC: HDC; X, Y: TCoordinate; Card: TCardId;

  Mode: Cardinal; Color: TColorRef): Bool;

{$IFDEF Win32}stdcall; {$endif

Win32}

function cdtDrawExt(aDC: HDC; X, Y, Width, Height: TCoordinate; Card: TCardId;

  Mode: Cardinal; Color: TColorRef): Bool;

{$IFDEF Win32}stdcall; {$endif

Win32}

procedure cdtTerm;

{$IFDEF Win32}stdcall;

{$ENDIF Win32}

function cdtAnimate(aDC: HDC; Card: TCardId; X, Y: TCoordinate;

  AnimateIndex: Word): Bool;

{$IFDEF Win32}stdcall;

{$ENDIF Win32}

type

  TZFPlayCard = class(TGraphicControl)

  private

    FCardId: TCardId;

    FDragging: Boolean;

    FDragMove: Boolean;

    FX, FY: Integer;

    FCardMode: TCardMode;

    FGlyph: TBitmap;

    procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;

    procedure ReDraw;

    procedure SetCardId(const Value: TCardId);

    procedure SetCardMode(const Value: TCardMode);

    procedure SetGlyph(const Value: TBitMap);

  protected

    procedure Paint; override;

  public

    constructor Create(AOwner: TComponent); override;

    destructor Destroy; override;

 

  published

    property CardMode: TCardMode read FCardMode write SetCardMode;

    property CardID: TCardId read FCardId write SetCardId default 1;

    property Glyph: TBitmap read FGlyph write SetGlyph;

    property Enabled;

    property Visible;

    property OnClick;

    property OnDblClick;

    property OnMouseDown;

    property OnMouseMove;

    property OnMouseUp;

  end;

 

procedure Register;

 

implementation

const

{$IFDEF win32}

  sCardsDLL = 'CARDS.DLL';

{$ELSE}

  sCardsDLL = 'CARDS';

{$ENDIF win32}

 

{$IFDEF win32}

function cdtInit; external sCardsDLL name 'cdtInit';

function cdtDraw; external sCardsDLL name 'cdtDraw';

function cdtDrawExt; external sCardsDLL name 'cdtDrawExt';

procedure cdtTerm; external sCardsDLL name 'cdtTerm';

function cdtAnimate; external sCardsDLL name 'cdtAnimate';

{$ELSE}

function cdtInit; external sCardsDLL index 1;

function cdtDraw; external sCardsDLL index 2;

function cdtDrawExt; external sCardsDLL index 3;

procedure cdtTerm; external sCardsDLL index 4;

function cdtAnimate; external sCardsDLL index 5;

{$ENDIF win32}

 

procedure Register;

begin

  RegisterComponents('Standard', [TZFPlayCard]);

end;

 

{ TZFPlayCard }

 

{procedure TZFPlayCard.Click;

begin

  inherited;

 

end;

}

 

未完,請看下一章。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved