How can I close mdiChilds from the mdiFrame-Window?

Forums for specific tips, techniques and example code
basti
Posts: 13
Joined: Tue Oct 13, 2009 10:39 am

How can I close mdiChilds from the mdiFrame-Window?

Postby basti » Sat Oct 17, 2009 6:43 pm

Hi,

I would like to close all mdiChilds before opening a new one.

Something like:

Code: Select all

mnuReport_click(menuItem: MenuItem input) updating; vars form:Report; begin mdiFrame.closeAllOpenChilds; //<-- How can I do this? create form; form.show; end;
I´m still a little bit confused how to access open forms from other open forms :?: .

Appreciate any help :) ! Thanks!

User avatar
Dino
Posts: 49
Joined: Wed Jun 24, 2009 6:55 am
Location: London
Contact:

Re: How can I close mdiChilds from the mdiFrame-Window?

Postby Dino » Sun Oct 18, 2009 1:08 am

Assuming closeAllOpenChilds is invoked on the MDI frame form itself, give this a go.

Code: Select all

closeAllOpenChilds(); // assumes this is being invoked for the MDI frame form vars i, n : Integer; f : Form; begin n := app.formsCount; // use reversed because forms move down in the list as other forms are closed, // so if you iterate forwards, you can get an exception closing the last form foreach i in 1 to n reversed do f := app.forms(i); // skip self, which is assumed to be the MDI frame if f <> self then if not f.unloadForm then // queryUnload event rejected the unload endif; endif; endforeach; end;
Dean.

User avatar
Dino
Posts: 49
Joined: Wed Jun 24, 2009 6:55 am
Location: London
Contact:

Re: How can I close mdiChilds from the mdiFrame-Window?

Postby Dino » Sun Oct 18, 2009 1:13 am

Just thought that instead of "reversed", you could do this as well, which might be more familiar.

Code: Select all

foreach i in n to 1 step -1 do
Dean.

basti
Posts: 13
Joined: Tue Oct 13, 2009 10:39 am

Re: How can I close mdiChilds from the mdiFrame-Window?

Postby basti » Sun Oct 18, 2009 1:33 pm

Thanks! It worked right off the bat :) .


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 9 guests

cron