1,2回答基本正确!至于3?自己到VCL中找原因!procedure TCustomForm.Close; var CloseAction: TCloseAction; begin if fsModal in FFormState then ModalResult := mrCancel else if CloseQuery then begin if FormStyle = fsMDIChild then//看这里,明白? if biMinimize in BorderIcons then CloseAction := caMinimize else CloseAction := caNone else CloseAction := caHide; DoClose(CloseAction); if CloseAction <> caNone then if Application.MainForm = Self then Application.Terminate//如果是主窗体就直接结束程序的原因也在这 else if CloseAction = caHide then Hide else if CloseAction = caMinimize then WindowState := wsMinimized else Release; end; end;
@地址,^地址内的值
MDI为什么我不知道,但我知道只有这样,我没有查细查过它的源码
比如:TForm1.Buttton1Click(Sender : TObjcet)
在这个过程里有一个Self指向TForm1
2、@相当于VC里的地址运算符&
^相当于VC里的 *,表示为指针
3、不知道原因。
2、@取地址
^指针
3、这是delphi本身的问题,不同语言对mdi的封装不同,delphi对midchild的关闭设了四种方式,但delphi默认的关闭方式为最小化,所以你需要将他的关闭方式修改才能够关闭窗口,如将Action := Free,将关闭方式改为关闭并释放资源
1.Self准确的说是类实现中,引用类自身对象的一种方法。
例如
TMyButton = class(TObject)
...
public
procedure Do;
end;
如果这个类有个方法:
procedure TMyButton.Do;
begin
//这里写Self就是指TMyButton的对象自己
end;
从上面加以引申,一般我们写程序(我指用Delphi)实际上就是在完成很多个
TForm类,在加入或者写该Form的方法,所以上面几位都指出Self是指窗体本
身,但是,这是不准确的,原因我上面已经说了。2.“@”是指获得某个变量或者过程(函数)的内存地址,
“^”用在变量声名的地方指该变量是个指针型变量,^后面跟着的类型是该变量
指针所指向的内存区域的数据类型。
“^”在程序代码中一般跟随在指针类型变量后面,用来取得该变量指针所指向的
内存区域的数据。3.呵呵,这个为什么你看看VCL源码就知道。有时候看源码收获是很大的。
我就不说了,留给你自己研究吧。
2.@X表示X的地址,^有两个用途,当他出现在一个类型标志符前^TYPENAME,它表示
一个指向TypeName类型的变量的指针,当他出现在一个指针变量后面时Point^
表示对该指针解除引用,换句话说,他返回在指针缩指向的地址处保存的值。
3.习惯用法,呵呵!
var
CloseAction: TCloseAction;
begin
if fsModal in FFormState then
ModalResult := mrCancel
else
if CloseQuery then
begin
if FormStyle = fsMDIChild then//看这里,明白?
if biMinimize in BorderIcons then
CloseAction := caMinimize else
CloseAction := caNone
else
CloseAction := caHide;
DoClose(CloseAction);
if CloseAction <> caNone then
if Application.MainForm = Self then Application.Terminate//如果是主窗体就直接结束程序的原因也在这
else if CloseAction = caHide then Hide
else if CloseAction = caMinimize then WindowState := wsMinimized
else Release;
end;
end;