delphi7 constructor 问题

lk_t68 2013-09-06 02:51:39
delphi2010下代码如下:
TXRegionRect = packed record
X: Integer;
Y: Integer;
Width: Integer;
Height: Integer;
public
constructor TXRegionRect(AX,AY,AWidth,AHeight: Integer);
end;

constructor TXRegionRect.TXRegionRect(AX,AY,AWidth,AHeight: Integer);
begin
X := AX;
Y := AY;
Width := AWidth;
Height := AHeight;
end;
要想在delphi7用应该怎么改?
...全文
164 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
随行的太阳 2013-09-06
  • 打赏
  • 举报
回复
sololie 2013-09-06
  • 打赏
  • 举报
回复
直接写个普通函数代替构造函数就可以了

 TXRegionRect = packed record
    X: Integer;
    Y: Integer;
    Width: Integer;
    Height: Integer;
  end;

funciton CreateTXRegionRect(AX,AY,AWidth,AHeight: Integer):TXRegionRect;

function CreateTXRegionRect(AX, AY, AWidth, AHeight: Integer): TXRegionRect;
begin
  Result.X := AX;
  Result.Y := AY;
  Result.Width := AWidth;
  Result.Height := AHeight;
end;

// 调用
var
 r:TXRegionRect;
begin
 r := CreateTXRegionRect(111, 222, 333, 444);
end;

sololie 2013-09-06
  • 打赏
  • 举报
回复
d7不行吧,至少d2006

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧