Delphi - 如何在该表单上关闭来自WITHIN的表单?

use*_*073 4 forms delphi tframe

在Delphi 2010中,我创建一个表单,然后创建一个TFrame,将TFrame.Parent分配给表单,然后显示表单MODALLY.工作得很好......框架有一个DBNavigator,一个字段DBFields等.当用户点击发布/保存时,我想自动关闭表单.我尝试了一些东西,比如Close,Action = caFree,(DBNav.parent.parent)作为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;
Run Code Online (Sandbox Code Playgroud)

谢谢,

GS

Dav*_*nan 8

从框架类中的方法,您可以通过调用来访问主机表单GetParentForm.因此,以下内容将满足您的需求:

GetParentForm(Self).Close;
Run Code Online (Sandbox Code Playgroud)