type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; type///// TMyClass = class private x:Integer; y:integer; s:string; public constructor Create(xx:Integer;yy:Integer;ss:string);overload; procedure out; end;/////// var Form1: TForm1;
implementation
{$R *.dfm} constructor TMyClass.Create(xx:Integer;yy:Integer;ss:string);///// begin x := xx; y := yy; s := ss; end; procedure TMyClass.out;///// begin Form1.Canvas.TextOut(x, y, s);///// end;
procedure TForm1.Button1Click(Sender: TObject); var a:TMyClass;//// begin a := TMyClass.Create(100, 200, '百度知道');//// a.out;//// a.Free;//// end;
type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; TcustCls = class private Fx, Fy: Integer; Fs: string; public procedure outPut(x, y:Cardinal; s: string); end; var Form1: TForm1;
implementation
{$R *.dfm}
procedure Tcustcls.outPut(x, y: Cardinal; s: string); begin if (x > 0) and (y > 0) then begin fx := x; fy := y; fs := s; Form1.Canvas.TextOut(fx, fy, fs); end else ShowMessage('坐标错误'); end;
procedure TForm1.Button1Click(Sender: TObject); var myText: TcustCls; begin myText := TcustCls.Create; myText.outPut(60, 50, '代码测试.....'); myText.Free; end;