This doesn't directly answer your questions.  But, here's a take on it

Sounds like the thing to do in this case then is to figure out how many
forms you have and how many controls are being dynamically added and see
if there really is a resource issue.  

Here's an example:

Let's assume that you would have 5 forms with 3 controls per form.
That would mean there are 15 controls per application dynamically being
adjusted.  Now I am not sure of the overhead involved here with respect
to the controls of a given type, but let's say it's 300 bytes apiece for
argument's sake.  That's about 4.5K (300*15) of extra application size.
If you added some hairy code beast to dynamically add and remove
controls, with proper error checking, it's probably going to be larger
than those extra resources.

So in this case, it appears that the one-liner with extra resources
might be a more cost-effective solution.

Of course, the example is full of assumptions (resource sizes, compiled
code sizes, etc.), so actual results may vary.  If the resource size is
smaller, then this solution may be more favored.  If it's larger, then
the dynamic-code option may be more favored.

>From the peanut gallery...

Mike
> -----Original Message-----
> From: Daniel McCarty [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, April 27, 1999 5:13 PM
> To:   [EMAIL PROTECTED]
> Subject:      Re: Adding button at run-time (2.0)
> 
> [EMAIL PROTECTED] wrote:
> > 
> > >I've got some code where in a special case I want to add a button
> > >at run-time if a form opens.
> > 
> > Why don't you just always have the button there but hide it (set to
> not
> > usable)?  Then call FrmShowObject when you want to see it.
> 
>    ...because I want to do it across the entire app, for every
> form that opens.  For one form I'd agree that it's better to just
> show a hidden button, but for many forms I can't justify the wasted
> resources.
>    So if I add a button dynamically do I also need to free the
> allocated memory as well when the form closes?--or will the OS
> take care of it for me.
> 
> Thanks,
> Daniel.
> 
> 

Reply via email to