4个问题 ( 积分: 15 )

  • 主题发起人 主题发起人 del_today
  • 开始时间 开始时间
D

del_today

Unregistered / Unconfirmed
GUEST, unregistred user!
请教各路高手:

以下为一个克隆程序的全部代码,就此想问几个问题,请指教!谢了!

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;

type
TForm1 = class(TForm)
Button1: TButton;
ScrollBox1: TScrollBox;
Label1: TLabel;
CheckBox1: TCheckBox;
Label2: TLabel;
Button2: TButton;
Edit1: TEdit;
BitBtn1: TBitBtn;
SpeedButton1: TSpeedButton;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
procedure Button1Click(Sender: TObject);
procedure ClickComp(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
AForm: TForm;
begin
// clone the 'self' object
Application.CreateForm (
TFormClass(Self.ClassType), AForm);
// move the form and show it
AForm.Left := Left + 50;
AForm.Top := Top + 50;
AForm.Show;
end;

procedure TForm1.ClickComp(Sender: TObject);
var
ControlText: string;
begin
with TControlClass (Sender.ClassType).Create (self) do
begin
Parent := (Sender as TControl).Parent;
Left := (Sender as TControl).Left + 10;
Top := (Sender as TControl).Top + 10;
SetLength (ControlText, 50);
(Sender as TControl).GetTextBuf(
PChar(ControlText), 50);
ControlText := PChar(ControlText) + ' *';
SetTextBuf (PChar (ControlText));
end;
end;

end.

//******************************************
问题1:
语句TFormClass(Self.ClassType)中,TFormClass()是什么意思? Self.ClassType又是什么意思?

问题2:
语句with TControlClass (Sender.ClassType).Create (self) do中,
TControlClass ()是何意? Sender.ClassType又是何意?
这两个问题怎么在Delphi自身的help里,也查不到答案呀?请高手帮忙!

问题3:
语句Sender as TControl是什么意思?和with语句有关吗?

问题4:
Parent在这个程序中是什么意思?
 
请教各路高手:

以下为一个克隆程序的全部代码,就此想问几个问题,请指教!谢了!

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;

type
TForm1 = class(TForm)
Button1: TButton;
ScrollBox1: TScrollBox;
Label1: TLabel;
CheckBox1: TCheckBox;
Label2: TLabel;
Button2: TButton;
Edit1: TEdit;
BitBtn1: TBitBtn;
SpeedButton1: TSpeedButton;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
procedure Button1Click(Sender: TObject);
procedure ClickComp(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
AForm: TForm;
begin
// clone the 'self' object
Application.CreateForm (
TFormClass(Self.ClassType), AForm);
// move the form and show it
AForm.Left := Left + 50;
AForm.Top := Top + 50;
AForm.Show;
end;

procedure TForm1.ClickComp(Sender: TObject);
var
ControlText: string;
begin
with TControlClass (Sender.ClassType).Create (self) do
begin
Parent := (Sender as TControl).Parent;
Left := (Sender as TControl).Left + 10;
Top := (Sender as TControl).Top + 10;
SetLength (ControlText, 50);
(Sender as TControl).GetTextBuf(
PChar(ControlText), 50);
ControlText := PChar(ControlText) + ' *';
SetTextBuf (PChar (ControlText));
end;
end;

end.

//******************************************
问题1:
语句TFormClass(Self.ClassType)中,TFormClass()是什么意思? Self.ClassType又是什么意思?

问题2:
语句with TControlClass (Sender.ClassType).Create (self) do中,
TControlClass ()是何意? Sender.ClassType又是何意?
这两个问题怎么在Delphi自身的help里,也查不到答案呀?请高手帮忙!

问题3:
语句Sender as TControl是什么意思?和with语句有关吗?

问题4:
Parent在这个程序中是什么意思?
 
后退
顶部