I've got some code where in a special case I want to add a button
at run-time if a form opens. This works very well in OS 3.0 and
higher thanks to CtlNewControl, but I've been muddling through doing
the same thing in OS 2.0 and wanted to check that I'm doing this
right.
This is what I've got so far (and it works):
ctl = MemPtrNew(sizeof (ControlType) + StrLen(buttonStr) + 1);
ctl->id = idButtonStats;
ctl->bounds.topLeft.x = StatsButtonX;
ctl->bounds.topLeft.y = StatsButtonY;
ctl->bounds.extent.x = StatsButtonDX;
ctl->bounds.extent.y = StatsButtonDY;
ctl->attr.usable = true;
ctl->attr.enabled = true;
ctl->attr.leftAnchor = true;
ctl->attr.frame = standardButtonFrame;
ctl->style = buttonCtl;
ctl->font = stdFont;
ctl->group = 0;
ctl->text = (CharPtr) (ctl + 1);
StrCopy(ctl->text, buttonStr);
frm->objects[frm->numObjects].objectType = frmControlObj;
frm->objects[frm->numObjects].object.ptr = ctl;
frm->numObjects++;
My basic assumption is that the form objects _don't_ have to
be in contiguous memory, but if they're not all in the same chunk,
will memory still be freed when I delete the form?
Regards,
Daniel.