testimpl.pas
来自「《Delphi开发人员指南》配书原码」· PAS 代码 · 共 68 行
PAS
68 行
unit TestImpl;
interface
uses
ComObj, ActiveX, Srv_TLB, StdVcl;
type
TAutoTest = class(TAutoObject, IAutoTest)
protected
function Get_EditText: WideString; safecall;
function Get_ShapeColor: OLE_COLOR; safecall;
procedure Set_EditText(const Value: WideString); safecall;
procedure Set_ShapeColor(Value: OLE_COLOR); safecall;
function Get_ShapeType: TxShapeType; safecall;
procedure Set_ShapeType(Value: TxShapeType); safecall;
procedure ShowInfo; safecall;
end;
implementation
uses ComServ, SrvMain, TypInfo, ExtCtrls, Dialogs, SysUtils, Graphics;
function TAutoTest.Get_EditText: WideString;
begin
Result := FrmAutoTest.Edit.Text;
end;
function TAutoTest.Get_ShapeColor: OLE_COLOR;
begin
Result := ColorToRGB(FrmAutoTest.Shape.Brush.Color);
end;
procedure TAutoTest.Set_EditText(const Value: WideString);
begin
FrmAutoTest.Edit.Text := Value;
end;
procedure TAutoTest.Set_ShapeColor(Value: OLE_COLOR);
begin
FrmAutoTest.Shape.Brush.Color := Value;
end;
function TAutoTest.Get_ShapeType: TxShapeType;
begin
Result := TxShapeType(FrmAutoTest.Shape.Shape);
end;
procedure TAutoTest.Set_ShapeType(Value: TxShapeType);
begin
FrmAutoTest.Shape.Shape := TShapeType(Value);
end;
procedure TAutoTest.ShowInfo;
const
SInfoStr = 'The Shape''s color is %s, and it''s shape is %s.'#13#10 +
'The Edit''s text is "%s."';
begin
with FrmAutoTest do
ShowMessage(Format(SInfoStr, [ColorToString(Shape.Brush.Color),
GetEnumName(TypeInfo(TShapeType), Ord(Shape.Shape)), Edit.Text]));
end;
initialization
TAutoObjectFactory.Create(ComServer, TAutoTest, Class_AutoTest,
ciMultiInstance, tmApartment);
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?