Creation of forms at run – time

Here is a sample job to create forms at run-time. This code will show form with a tree structure in it.
static void formCreation(Args _args)
{
    Form                    form;
    FormTreeControl         tree;
    FormRun                 formRun;
    Args                    args;
    ImageList               imageList;
    int                     imageNum;
    int                     parentIdx;
    int                     treeItemIdx, treeItemIdx1;
    ImageRes                imageRes = imageNum;
    TreeNode                treeNode;
    ;
 
    form = new Form(‘Folder’, true);
    form.design().width(350);
    form.design().height(150);
    form.design().caption(‘Folder structure’);
    form.design().addControl(FormControlType::Tree, ‘TreeCtrl’);
 
    args = new Args(form.name());
    args.name(form.name());
    args.object(form);
 
    formRun = classFactory.formRunClass(args);
    formRun.init();
    formRun.run();
 
    tree = formRun.design().controlName(‘TreeCtrl’);
    tree.width(330);
    tree.height(130);
    tree.hasButtons(false);
    tree.border(3);
    tree.colorScheme(2);
    tree.backgroundColor(11072224);
    tree.font(‘Verdana’);
    tree.fontSize(8);
    tree.bold(7);
 
    imagelist = new Imagelist(25, 25);
    imageNum = imagelist.add(new Image(3114));
 
    tree.setImagelist(imagelist);
    tree.deleteAll();
 
    parentIdx = SysFormTreeControl::addTreeItem(Tree,
                                                ‘SamTest’,
                                                FormTreeAdd::Root,
                                                ‘Data on root’,
                                                imageRes,
                                                true);
    treeItemIdx = SysFormTreeControl::addTreeItem(Tree,
                                                ‘Test1’,
                                                parentIdx,
                                                ‘Data on element2’,
                                                imageRes,
                                                true);
    treeItemIdx1 = SysFormTreeControl::addTreeItem(Tree,
                                                ‘Test2’,
                                                treeItemIdx,
                                                ‘Data on element3’,
                                                imageRes,
                                                false);
    SysFormTreeControl::expandTree(Tree, Tree.getRoot(), 3);
    formRun.detach();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s