Page 1 of 1
How can I close mdiChilds from the mdiFrame-Window?
Posted: Sat Oct 17, 2009 6:43 pm
by basti
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!
Re: How can I close mdiChilds from the mdiFrame-Window?
Posted: Sun Oct 18, 2009 1:08 am
by Dino
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.
Re: How can I close mdiChilds from the mdiFrame-Window?
Posted: Sun Oct 18, 2009 1:13 am
by Dino
Just thought that instead of "reversed", you could do this as well, which might be more familiar.
Dean.
Re: How can I close mdiChilds from the mdiFrame-Window?
Posted: Sun Oct 18, 2009 1:33 pm
by basti
Thanks! It worked right off the bat

.