Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:23 pm
by Patwos >> Fri, 5 Sep 2008 4:06:54 GMT
Programmatically adjusting forms etc is not officially supported in any form. Assuming all you're wanting to do is programmatically adjust say captions or positioning of existing controls then you need to be aware that you're dealing with a persistent instance of the Form class not an instance of your form subclass.
Once you have a reference to the appropriate Form class instance you can use the controlCount and controls methods to iterate each existing control and process as appropriate. For example, the following code snippet process the caption for most of the controls on a form that are of a control type that have a caption:
foreach ctlIndex in 1 to f.controlCount do
ctl := f.controls( ctlIndex );
if ctl.isKindOf( Button ) then
self.processCaption( ctl.Button.caption );
elseif ctl.isKindOf( CheckBox ) then
self.processCaption( ctl.CheckBox.caption );
elseif ctl.isKindOf( Frame ) then
self.processCaption( ctl.Frame.caption );
elseif ctl.isKindOf( GroupBox ) then
self.processCaption( ctl.GroupBox.caption );
elseif ctl.isKindOf( JadeDockBase ) then
self.processCaption( ctl.JadeDockBase.caption );
elseif ctl.isKindOf( Label ) then
self.processCaption( ctl.Label.caption );
elseif ctl.isKindOf( OptionButton ) then
self.processCaption( ctl.OptionButton.caption );
elseif ctl.isKindOf( JadeMask ) then
self.processCaption( ctl.JadeMask.caption );
elseif ctl.isKindOf( StatusLine ) then
self.processCaption( ctl.StatusLine.caption );
endif;
endforeach;
Be aware that this will not affect the formBuildData that is used at runtime to improve the runtime performance. You can correct this by opening all your top level superforms, that are direct decendents of Form, in the Jade Painter and saving the form to force the formBuildData to be rebuilt.
If you're wanting to do things like adding additional controls etc, then use the Jade Painter as there is too much behind the scenes meta data changes that you won't have access to running as a non-system application - especially given that programmatically changing your meta-data in this way is not officially supported.
Hope that helps,
Pat.