dynamically create controls on controls

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

dynamically create controls on controls

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

by Jens Richnow >> Thu, 20 Jan 2000 20:17:35 GMT

I need to dynamically create and add controls on controls. For instance, dynamically create a picture on a form (which can be done with ...addControl method) and then dynamically create other pictures on this first created picture.

I tried to use the .windowCreated method of the control for creating the new pictures. It creates the new pictures and I can set the parent but the new pictures are not displayed on the parent picture.

Could somebody give me help on this?

Thanks a lot

Jens Richnow

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

Re: dynamically create controls on controls

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

by Torrie Moore >> Thu, 20 Jan 2000 21:04:30 GMT

Jens.

We have a couple of tab sheets that we dynamically create controls on. The following code example creates a frame and a button.
In terms of the controls not appearing perhaps you need to call the refresh method on parent control. We have also put event code on the buttons but this gets complicated as you need to ensure that the event method exisits on the form that the control is placed on.

Hope this helps
Torrie Moore
Concept Engineering


windowCreated(cntrl : Control input; persistCntrl : Control) updating;

vars
begin


create gbFrame transient;
gbFrame.parent := self;
gbFrame.name := self.name & 'gbFrame';
gbFrame.caption := $Str_Notes;
gbFrame.backColor := CntrlBackColor;
self.form.addControl(gbFrame);
gbFrame.tabIndex := self.tabIndex + 1;

create bnAdd transient;
bnAdd.parent := gbFrame;
bnAdd.name := self.name & "bnAdd";
bnAdd.caption := $Str_bnNew;
bnAdd.enabled := true;
bnAdd.centreCaption := true;
self.form.addControl(bnAdd);
bnAdd.tabIndex := self.tabIndex + 2;

// Should be converting app.formMargin etc to dialog units!
gbFrame.top := app.formMargin;
gbFrame.left := app.formMargin;
gbFrame.width := self.clientWidth - 2*app.formMargin;
gbFrame.height := self.clientHeight - 2*app.formMargin;

bnAdd.top := gbFrame.clientHeight - app.formMargin - bnAdd.height;
bnAdd.left := app.formMargin;

self.refresh;
inheritMethod(cntrl,persistCntrl);


end;

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

Re: dynamically create controls on controls

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

by Jens Richnow >> Thu, 20 Jan 2000 23:18:31 GMT

Torrie,

thanks a lot! It works fine now. I missed the point of adding the new control to the form!
self.form.addControl(gbFrame);


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 30 guests