在Delphi 2010中,我創建一個表單,然後創建一個TFrame,將TFrame.Parent分配給表單,然後顯示錶單MODALLY。工作正常...框架有一個DBNavigator,一個字段DBFields等。當用戶點擊發布/保存時,我想自動關閉表單。我已經嘗試了一些東西,例如Close,Action = caFree,(DBNav.parent.parent)作爲TForm.Free等等,但似乎沒有任何工作。我如何 - 從TFrame內關閉表格?德爾福 - 如何關閉窗體內的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的子類。 –
這裏沒有必要,@馬庫斯。 「釋放」用於表單從表單的消息處理程序或其控件之一中銷燬。從這裏顯示的代碼中,表單在'Free'被調用時處理任何消息是不可能的,所以一切都很好。 –