【发布时间】:2013-09-28 13:43:20
【问题描述】:
在 Delphi 2010 中,我正在创建一个表单,然后创建一个 TFrame,将 TFrame.Parent 分配给该表单,然后以模式方式显示该表单。工作正常...框架有一个 DBNavigator、一个字段 DBFields 等。当用户点击发布/保存时,我想自动关闭表单。我尝试了一些方法,例如 Close、Action = caFree、(DBNav.parent.parent) as TForm.Free 等,但似乎没有任何效果。我如何 - 从 TFrame 中关闭表单?
创建这个东西的代码是......
// Create the Window
ThisWin := TEmptyFrameWin.Create(nil);
// Create the Frame for the Window
ThisFrame := TFrameUsage.Create(Application);
ThisFrame.Parent := ThisWin;
// Load the data
ThisFrame.tUsage.Open;
ThisFrame.tUsage.FindKey([StrToInt(ID)]);
ThisFrame.LoadDateFields;
ThisWin.Caption := 'Change Appointment Information';
// Only show the POST button
ThisFrame.UsageNav.VisibleButtons := [sbPost];
try
ThisWin.ShowModal;
finally
ThisWin.Free;
end;
谢谢,
GS
【问题讨论】:
-
对 TForm 的子类使用
Release而不是Free。 -
这里没有必要,@Marcus。
Release用于从表单或其控件之一的消息处理程序中销毁表单时。从这里显示的代码来看,表单不可能在调用Free时处理任何消息,所以一切都很好。