Cannot Create Form No Mdi Forms Are Currently Active Error
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up “Cannot create form. No MDI forms are currently active” error up vote 4 down vote favorite I have a MDI main (parent) form and a MDI child form. I create the child at runtime like this: VAR FrmDereplic: TFrmDereplic; procedure TMainFrm.Button2Click(Sender: TObject); begin FrmDereplic:= TFrmDereplic.Create(MainFrm); FrmDereplic.Show; end; Steps to reproduce the error: I start the app, I press the button to create the child, I press the 'x' button on main (parent) form to close the application and I get an "Cannot create form. No MDI forms are currently active" error. The line on which the error appears is in the child form: procedure TFrmDereplic.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:= caFree; end; procedure TFrmDereplic.FormDestroy(Sender: TObject); VAR MyIniFile: TCubicIniFile; begin MyIniFile:= TCubicIniFile.Create(AppINIFile); TRY with MyIniFile DO begin if WindowState<> wsMaximized then begin // save form's screen pos ... end; WriteInteger ('Dereplicator', 'fltExtensions', fltExtensions.ItemIndex); <----- HERE FINALLY FreeAndNil(MyIniFile); END; end; I save lots of form's properties (and other's controls properties) to the INI file. But it only fails when I try to save fltExtensions.ItemIndex (which is a TFilterComboBox). If I comment that line it works perfectly. Any idea why it tries to create a form when I actually closed the application????????? delphi share|improve this question edited Oct 16 '10 at 18:53 asked Oct 16 '10 at 13:22 Silvester 7,803774179 add a comment| 3 Answers 3 active oldest votes up vote 5 down vote accepted I look on some web sites and just found the problem. It looks like is better if Owner is the Application, not the main form. Remy Lebeau suggests that the real problem is in the OnDestroy of the the child form. There is no valid handle t
currently active. Reply to this Thread Search Forum Back to Thread List Replies: 4 - Last Post: Jan 5, 2015 4:30 PM Last Post By: Remy Lebeau (Te... Edmund Wong Posts: 97 Registered: 10/26/02 Cannot create form. No MDI forms are currently active. Reply Posted: Jan 5, 2015 1:31 AM Hi, It's been a while since I last worked on a Delphi project and I'm quite rusty in Delphi. I have a MDI form and a child form. In the main MDIForm, I have the following that runs when a configuration file isn't found: cd := TConfigDialog.Create(nil); cd.ShowModal; PostMessage(self.handle, WM_CLOSE, 0, 0); Screen.Cursor := crDefault; But once it hits the first http://stackoverflow.com/questions/3949049/cannot-create-form-no-mdi-forms-are-currently-active-error line, it gives me the warning as mentioned in the subject. I wrote this code a while back and I'm not exactly sure what the PostMessage() part does right now; but I think it closes the main form as well when the configuration dialog closes. Can someone point out which part of the project configuration do I set the MDI form active? Thanks Edmund Remy Lebeau (Te... Posts: 6,626 Registered: 12/23/01 Re: Cannot https://forums.embarcadero.com/thread.jspa?threadID=111418 create form. No MDI forms are currently active. Reply Posted: Jan 5, 2015 10:46 AM in response to: Edmund Wong Edmund wrote: In the main MDIForm, I have the following that runs when a configuration file isn't found:
on my first MDI project. I've created a project using the wizard, no problem. Now I have 3 forms: - a login form frmLogin.pas (fsStayOnTop) - main form frmMain.pas (fsMDIForm) - Child form frmChild.pas (fsMDIChild) After http://www.delphigroups.info/2/3d/312439.html logging on a procedure on the main form is called procedure TfrmMain.CreateMDIChild(const Name: string); var Child: TfrmProductTPL; begin { create a new MDI child window } Child := TfrmProductTPL.Create(Application); Child.Caption := Name; end; It raizes an error: Cannot create form. No MDI forms are currently active. I pretty much stuck, hope someone will lend me a hand. Ronan Symantec Petter Holmstr? Delphi Developer Tue, 22 Jan 2002 03:00:00 GMT Re:MDI: Cannot cannot create create form. No MDI forms are currently active Try this: frmChild := TfrmChild.Create(Self); frmChild.Caption := Name; No guaranties! -Petter- QuoteRonan van Riet wrote: > Hi, > I've just started working on my first MDI project. I've created a > project using the wizard, no problem. > Now I have 3 forms: > - a login form frmLogin.pas (fsStayOnTop) > - main form frmMain.pas (fsMDIForm) > - Child form frmChild.pas (fsMDIChild) > After logging on a procedure cannot create form on the main form is called > procedure TfrmMain.CreateMDIChild(const Name: string); > var > Child: TfrmProductTPL; > begin > { create a new MDI child window } > Child := TfrmProductTPL.Create(Application); > Child.Caption := Name; > end; > It raizes an error: Cannot create form. No MDI forms are currently > active. > I pretty much stuck, hope someone will lend me a hand. > Ronan > Symantec -- Petter Holmstr?m E-mail: mailto:petter.holmst...@parnet.fi Home page: http://www.parnet.fi/~pkh/ Team Delphi Developer Wed, 23 Jan 2002 03:00:00 GMT Re:MDI: Cannot create form. No MDI forms are currently active In article <37AB334F.D90DC...@{*word*104}tech.demon.nl>, Ronan van Riet stated: Quote> It raizes an error: Cannot create form. No MDI forms are currently > active. This indicates that the FormStyle property of the main form isn't set to fsMDIForm -- Regards Ralph (TeamB) -- Team Delphi Developer Wed, 23 Jan 2002 03:00:00 GMT Re:MDI: Cannot create form. No MDI forms are currently active Quote> I've just started working on my first MDI project. I've created a > project using the wizard, no problem. > Now I have 3 forms: > - a login form frmLogin.pas (fsStayOnTop) > - main form frmMain.pas (fsMDIForm) > - Child form frmChild.pas (fsMDIChild) > After logging on a procedure on the main form is called > procedure TfrmMain.CreateMDIChild(const Name: string); > var > Child: TfrmPr