"Creative Digital Publishing Inc." wrote:
> 
> >       I need to create button dynamically, because the number of button
> >to be is different every time. anybody point me the way?
> 
> I don't know if there's a way to do that, but you could always have all the
> buttons you need as part of the form and show and hide them as the need
> arises. It's kind of brute force, but it should work.

   With OS 3.0 and greater you can use CtlNewControl to create
dynamic controls.  This should be what you're looking for.  If
you want to support versions of the OS lower than that (2.x
especially), you'll have to use some code like this:

   ctl = MemPtrNew(sizeof (ControlType) + StrLen(buttonStr) + 1);

   // set ctl->[all properties] here

   frm->objects[frm->numObjects].objectType = frmControlObj;
   frm->objects[frm->numObjects].object.ptr = ctl;
   frm->numObjects++;
   // draw control, or redraw entire form

   Note that you'll need to handle freeing the memory you've
allocated, as the OS will _not_ do it when it destroys the
form.

Regards,
Daniel.

   p.s.  Eric, it would help if you described what problems
you're having and what steps you've taken to try to solve
them, instead of posting "random" one-liners without giving
anyone a clue as to what you're really trying to do.

Reply via email to