Delphi 之运算符重载
Delphi 7之后的版本,增加了运算符的重载。虽然不尽人意(需要写特定英文),但有总比没有强。
例:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
T3DPoint = record
X, Y, Z: Double;
class operator ADD(ALeftPoint, ARightPoint: T3DPoint): T3DPoint; {重载'+'运算符}
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ T3DPoint }
class operator T3DPoint.ADD(ALeftPoint, ARightPoint: T3DPoint): T3DPoint;
begin
Result.X := ALeftPoint.X + ARightPoint.X;
Result.Y := ALeftPoint.Y + ARightPoint.Y;
Result.Z := ALeftPoint.Z + ARightPoint.Z;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
A, B, Z: T3DPoint;
begin
A.X := 1; A.Y := 1; A.Z := 1;
B.X := 3; B.Y := 3; B.Z := 3;
Z := A + B;
ShowMessageFmt('%f, %f, %f', [Z.X, Z.Y, Z.Z]); {4.00, 4.00, 4.00}
//ShowMessage(FloatToStr(Z.X) + ',' + FloatToStr(Z.Y) + ',' + FloatToStr(Z.Z)); {4, 4, 4}
end;
end.
下面附上所有的运算符:
重载特定英文 行为(或目数) 方法 &nbs
相关文档:
Delphi字符串函数大全
uses StrUtils;
【字符串函数大全】
首部 function AnsiResemblesText(const AText, AOther: string): Boolean;
$[StrUtils.pas
功能 返回两个字符串是否相似
  ......
delphi dll 实例 与 dll窗体实例
本动态链接库方法有
Min,Max,SynAPP,ShowForm,showmyform
dll工程文件
Library Project1;
uses
dllUnit1 in 'dllUnit1.pas' {Form1};
function Min(X, Y: Integer): Integer; export;
begin
if X < Y then Min := X else Min := Y;
end;
function Max(X, Y: Integer): ......
delphi 注册 com 对象的方法
procedure TForm1.Button3Click(Sender: TObject);
var
Sd: TSecurityDescriptor;
begin
InitializeSecurityDescriptor(@Sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(@Sd, true, Nil, false);
RegSe ......
http://meidi152.blog.163.com/blog/static/5423302009610103610744/
1. memo控件读取txt
memo1.Lines.LoadfromFile('E:\*\*.txt');
2.
Procedure NewTxt(FileName:String);
Var
F : Textfile;
Begin
if fileExists(FileName) then DeleteFile(FileName); {看文件是否存在,在就刪除}
AssignFile(F, ......