易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi 设计模式:《HeadFirst设计模式》Delphi7代码

模板方法模式定义了一个算法骨架,允许子类对算法的某个或某些步骤进行重写(override)。
1.CoffeineBeverageWithHook
{《HeadFirst设计模式》之模板方法模式 }
{ 编译工具: Delphi7.0 }
{ E-Mail : xshlife@163.com }

unit uCoffeineBeverageWithHook;

interface

uses
SysUtils;

type
TCoffeineBeverageWithHook = class(TObject)
protected
procedure BoilWater;
procedure Brew; virtual; abstract;
procedure PourInCup;
procedure AddCondiments; virtual; abstract;
function CustomerWantsCondiments: Boolean; virtual; { 钩子 }
public
procedure PrepareRecipe; { 模板方法 }
end;

TCoffeeWithHook = class(TCoffeineBeverageWithHook)
private
function GetUserInput: string;
public
procedure Brew; override;
procedure AddCondiments; override;
function CustomerWantsCondiments: Boolean; override;
end;

TTeaWithHook = class(TCoffeineBeverageWithHook)
private
function GetUserInput: string;
public
procedure Brew; override;
procedure AddCondiments; override;
function CustomerWantsCondiments: Boolean; override;
end;

implementation

{ TCoffeineBeverageWithHook }

procedure TCoffeineBeverageWithHook.BoilWater;
begin
Writeln('Boiling Water');
end;

function TCoffeineBeverageWithHook.CustomerWantsCondiments: Boolean;
begin
Result := True;
end;

procedure TCoffeineBeverageWithHook.PourInCup;
begin
Writeln('Poiling into cup');
end;

procedure TCoffeineBeverageWithHook.PrepareRecipe;
begin
BoilWater;
Brew;
PourInCup;
if CustomerWantsCondiments then
AddCondiments;
end;

{ TCoffeeWithHook }

procedure TCoffeeWithHook.AddCondiments;
begin
Writeln('Add Sugar and Milk');
end;

procedure TCoffeeWithHook.Brew;
begin
Writeln('Drip Coffee Through Filter');
end;

function TCoffeeWithHook.CustomerWantsCondiments: Boolean;
var
Answer: string;


相关文档:

Delphi图像处理

    设置图像关键颜色,使图像的某种或某个范围的颜色成为透明色,是图片合成、动画显示中经常用的图像处理手段。下面是实现代码:
过程定义:
// 设置色键(透明范围)。colorLow 低色键值; colorHigh 高色键值
// 当像素A、R、G、B值同时大于等于colorLow和小于等于colorHigh时为透明色
procedu ......

delphi 2010 fastMM 内存泄露使用方法

Delphi2010集成了fastMM,这回大家调试程序是的时候可以方便地检查内存泄露了。
使用方法如下:
在project中,添加一行 ReportMemoryLeaksOnShutdown := DebugHook<>0;
DebugHook<>0 目的是保证单独运行exe文件不会弹出内存泄露框,源码可以不用注释掉此行
program Project1;
uses
  Forms,
  ......

Delphi 设计模式:《HeadFirst设计模式》Delphi代码

一、一个叫声接口和几只鸭子
1、从一个叫声接口开始
{《HeadFirst设计模式》Delphi代码之模式小结 }
{ 一个叫声接口 }
{ 编译工具:Delphi2010 for win32 }
{ E-Mail :xshlife@163.com }

unit uQuackable;

interface

type
IQuackable = in ......

delphi 类成员信息地址分析

 //定义MyClass
TMyClass = class
GUID: string;
Name: string;
bSex: Boolean;
Tel : string;
end;
//取值
var
obj: TMyClass;
begin
obj := TMyClass.Create;
with Memo1.Lines do
begin
Add('对象大小:' + IntToStr(obj.InstanceSize));
Add('对象所在地址:'+ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号