Count of MDI Child Form

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Count of MDI Child Form

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:53 pm

by Ian Cox >> Mon, 18 Apr 2005 19:29:49 GMT

I wish to code a situation where I disable controls on an MDI Form when the last MDI Child is closed. I have the MDI Child superclass calling a method on its MDI Frame in the form::Unload event I now need a count of the child forms open. DO I need to maintain this or can I get it from the Form/window object?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Count of MDI Child Form

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:53 pm

by T Moore >> Tue, 19 Apr 2005 7:48:55 GMT

You can get the list of forms open using the Application::forms and Application::formsCount methods on the application class. You will need to check the Form::getMDIFrame method to find the forms that are children of the current frame. For example a method on the MDI Frame. Note you may need to exclude the form just closed.

vars
form : Form;
indx : Integer;
iChildCount : Integer;begin

foreach indx in app.formsCount to 1 step -1 do
form := app.forms(indx);
if form.getMdiFrame=self then
// Form is an MDI child of this frame.
iChildCount := iChildCount + 1;
endif;
endforeach;
end;

You could also create an inverse relationship between the MDIFrame and the MDIChild forms. When the MDI child is opened it could set it's MDIFrame reference. Then the count of child forms would simply be the size of the collection.

Torrie


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 28 guests