In Delphi 2010, I am creating a form, and then creating a TFrame, assigning TFrame.Parent to the form, and then showing the form MODALLY. Works fine... The frame has a DBNavigator, a field DBFields,etc. When the user clicks on Post/Save, I want to automatically close the Form. I have tried a few things, such as Close, Action = caFree, (DBNav.parent.parent) as TForm.Free, etc and nothing seems to work. How do I - from within a TFrame, close the Form?
Code to create this thing is...
// 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;
Thanks,
GS
From a method within the frame class, you can reach the host form by calling GetParentForm
. So, the following would meet your needs:
GetParentForm(Self).Close;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With