How To get all child forms ?

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

How To get all child forms ?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:16 pm

by Didier >> Sat, 2 Feb 2008 5:16:12 GMT

Hi,
1) create a form named frmParent ;
2) create others forms named frmChild1, frmChild2,... and setFormParent whith frmParent ;

how to get all child forms of frmParent ?

Appreciate for any help .

Didier
2008.2.2

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

Re: How To get all child forms ?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:16 pm

by Torrie Moore >> Sun, 3 Feb 2008 20:35:53 GMT

Unfortunately there is no inverse to the form parent. The only way to get the parent is to enumerate through the open forms and query their parent.

vars
i : Integer;
oParent : Form;begin

oParent := what ever parent form you're interested in;

foreach i in 1 to app.formsCount do
if app.forms(i).getFormParent = oParentForm then
// This form is a child form of oParent
endif;
endforeach;

If you need to access the form's parent and children, then you could setup an inverse between the forms. We have created a common superclass form which has this defined. All our forms are subclasses of this common form. For example on the child form add a myParent reference inversed to a collection allChildren on the parent form. (You may need to create a collection of forms, e.g. FormArray or FormSet etc. There is a FormNameDict (see Locale::getForms) but this may not work if you open the same form twice.) You can then reimplement the setFormParent method to also set your reference.

setFormParent(form: Form) updating;
// Sets the form parent.begin

inheritMethod(form); // Let Jade do its stuff
myParentForm := form; // Also set the local reference
end;

Cheers

Torrie

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

Re: How To get all child forms ?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:16 pm

by cnwtb2 >> Sun, 3 Feb 2008 22:57:36 GMT

....or you could get the class names of the child forms by using the Class::allLocalSubclasses method (and other such methods) and manipulate the Class(s) returned. i.e.

(note: FrmParent is the Class not the Object of a Class)

vars
oClassColl : ClassColl;
oChildClass: Class;
begin
create oClassColl transient;
FrmParent.allLocalSubclasses(oClassColl);

foreach oChildClass in oClassColl do
write oChildClass.name; // manipulate the findings
endforeach;
epilog
delete oClassColl;
end;


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 12 guests