Run time Control Array and Dynamic Form Generation 
Author Message
 Run time Control Array and Dynamic Form Generation

Hi People,
This is my maiden question in this forum.
I am creating dynamic forms(How many? Variable...) and then adding dynamic
control(..Command button) on each dynamic form using following code

    Set cmdZoom = d_form(i).Controls.Add("VB.CommandButton", "cmdZoom")
Now I want to know which command button is clicked and in which form by
handling click event.But thing is that i get  event of lastly added command
button only.I want to handle click event of any button like control array.But
this is not control array coz each control is on different forms.So,my
Question is that how do I know which button is clicked and on which form.
Info:--- Each dynamic command button has same name.I am Using VB6

Thanks.



Sat, 18 Dec 2010 03:14:00 GMT  
 Run time Control Array and Dynamic Form Generation

Quote:

> Hi People,
> This is my maiden question in this forum.
> I am creating dynamic forms(How many? Variable...) and then adding dynamic
> control(..Command button) on each dynamic form using following code

If it was a good idea, there would be plenty of tutorials
available for everyone to follow.

But in general it is not.

Maybe you could explain what you need to accomplish
and why you think so much 'dynamic' ...stuff ...
is a useful approach.

        Bob
--
If you have to ask, maybe you're already in over your head.



Sat, 18 Dec 2010 06:22:02 GMT  
 Run time Control Array and Dynamic Form Generation
On Mon, 30 Jun 2008 12:14:00 -0700, Arv212

Quote:

>Hi People,
>This is my maiden question in this forum.
>I am creating dynamic forms(How many? Variable...) and then adding dynamic
>control(..Command button) on each dynamic form using following code

>    Set cmdZoom = d_form(i).Controls.Add("VB.CommandButton", "cmdZoom")
>Now I want to know which command button is clicked and in which form by
>handling click event.But thing is that i get  event of lastly added command
>button only.I want to handle click event of any button like control array.But
>this is not control array coz each control is on different forms.So,my
>Question is that how do I know which button is clicked and on which form.
>Info:--- Each dynamic command button has same name.I am Using VB6

I would recommend using a control array if possible. If not, it's a
little more difficult.

You could wrap each control in a usercontrol. When the event is fired
from the original control, the wrapper control can call a subroutine
in the form. Something along these lines (all air code):

'Partial Usercontrol code
Private Sub HostedButton_Click()
    ParentForm.ButtonClicked Extender.Name
End Sub

'Partial form code
Public Sub ButtonClicked(ByVal ControlName As String)
    'Act on the click here, based on ControlName
End Sub

It would be even better to have the host form and wrapper usercontrol
implement common interfaces :

'IHostForm.cls
Option Explicit
Public Function AddControl(ByVal ProgID As String, ByVal Name As
String) As IControl
End Function
Public Sub ButtonClicked(ByVal ControlName As String)
End Sub

'IControl.cls
Option Explicit
Public Sub SetInfo(ByVal Parent As IHostForm)
End Sub

It works quite well, but you'd probably need a better example than I
can give (coffee not working today). If so, let me know and I'll put
one together for you.

Quote:
>Thanks.

        J.
    Jeremiah D. Seitz
    Omega Techware
    http://www.omegatechware.net


Sat, 18 Dec 2010 22:00:12 GMT  
 Run time Control Array and Dynamic Form Generation

Hi,
Let me explain you what I want to accomplish.
i am creating forms at run time depending upon user's selection.Each form
has one command button and one MODI control.MODI control displays .Tiff
formatted images in it.But it's too small.So I want to zoom it so that user
can see it in full screen view.For zoom purpose,I have added command button
on each form.So ,when user cliks on any so-called generated form's command
button,MODI control on that form should zoom itself.For that I want to handle
clik event of cliked command button and do zooming stuff.But I am only
getting click event of last generated form's command button.But I want it for
any command button on any generated form.
Thanks for your time and help.

Quote:


> > Hi People,
> > This is my maiden question in this forum.
> > I am creating dynamic forms(How many? Variable...) and then adding dynamic
> > control(..Command button) on each dynamic form using following code

> If it was a good idea, there would be plenty of tutorials
> available for everyone to follow.

> But in general it is not.

> Maybe you could explain what you need to accomplish
> and why you think so much 'dynamic' ...stuff ...
> is a useful approach.

>    Bob
> --
> If you have to ask, maybe you're already in over your head.



Sat, 18 Dec 2010 22:02:01 GMT  
 Run time Control Array and Dynamic Form Generation
Hi,
Let me explain you what I want to accomplish.
i am creating forms at run time depending upon user's selection.Each form
has one command button and one MODI control.MODI control displays .Tiff
formatted images in it.But it's too small.So I want to zoom it so that user
can see it in full screen view.For zoom purpose,I have added command button
on each form.So ,when user cliks on any so-called generated form's command
button,MODI control on that form should zoom itself.For that I want to handle
clik event of cliked command button and do zooming stuff.But I am only
getting click event of last generated form's command button.But I want it for
any command button on any generated form.
   Your suggested approaches are excellent.But I guess I would work with
static forms and controls.If you have any suggestions for above mentioned
criteria then pls help me out.
Thanks for your time and help.
Quote:

> On Mon, 30 Jun 2008 12:14:00 -0700, Arv212

> >Hi People,
> >This is my maiden question in this forum.
> >I am creating dynamic forms(How many? Variable...) and then adding dynamic
> >control(..Command button) on each dynamic form using following code

> >    Set cmdZoom = d_form(i).Controls.Add("VB.CommandButton", "cmdZoom")
> >Now I want to know which command button is clicked and in which form by
> >handling click event.But thing is that i get  event of lastly added command
> >button only.I want to handle click event of any button like control array.But
> >this is not control array coz each control is on different forms.So,my
> >Question is that how do I know which button is clicked and on which form.
> >Info:--- Each dynamic command button has same name.I am Using VB6

> I would recommend using a control array if possible. If not, it's a
> little more difficult.

> You could wrap each control in a usercontrol. When the event is fired
> from the original control, the wrapper control can call a subroutine
> in the form. Something along these lines (all air code):

> 'Partial Usercontrol code
> Private Sub HostedButton_Click()
>     ParentForm.ButtonClicked Extender.Name
> End Sub

> 'Partial form code
> Public Sub ButtonClicked(ByVal ControlName As String)
>     'Act on the click here, based on ControlName
> End Sub

> It would be even better to have the host form and wrapper usercontrol
> implement common interfaces :

> 'IHostForm.cls
> Option Explicit
> Public Function AddControl(ByVal ProgID As String, ByVal Name As
> String) As IControl
> End Function
> Public Sub ButtonClicked(ByVal ControlName As String)
> End Sub

> 'IControl.cls
> Option Explicit
> Public Sub SetInfo(ByVal Parent As IHostForm)
> End Sub

> It works quite well, but you'd probably need a better example than I
> can give (coffee not working today). If so, let me know and I'll put
> one together for you.

> >Thanks.

>    J.
>     Jeremiah D. Seitz
>     Omega Techware
>     http://www.omegatechware.net



Sat, 18 Dec 2010 23:30:01 GMT  
 Run time Control Array and Dynamic Form Generation

Quote:

> Hi,
> Let me explain you what I want to accomplish.
> i am creating forms at run time depending upon user's selection.Each
> form has one command button and one MODI control.MODI control
> displays .Tiff formatted images in it.But it's too small.So I want to
> zoom it so that user can see it in full screen view.For zoom
> purpose,I have added command button on each form.So ,when user cliks
> on any so-called generated form's command button,MODI control on that
> form should zoom itself.For that I want to handle clik event of
> cliked command button and do zooming stuff.But I am only getting
> click event of last generated form's command button.But I want it for
>   any command button on any generated form. Your suggested approaches
> are excellent.But I guess I would work with
> static forms and controls.If you have any suggestions for above
> mentioned criteria then pls help me out.
> Thanks for your time and help.

How do you create dynamic form instances at runtime?
And why do you need to create dynamically buttons also?

If each dynamic form had the same controls set, you could design a
"template" form (say frmTemplate), placing on it any button and controls you
like, e.g. cmdZoom.
Of course, the template form should handle its own controls' events
(cmdZoom_Click).

So, when you're creating form at runtime, you have nothing else to do but
create template instances:
Set d_form(i) = New frmTemplate

Since each instance of frmTemplate has its own controls set and events, you
don't even have to worry about catching buttons clicks in the "caller"
object.

Raf



Sun, 19 Dec 2010 00:25:48 GMT  
 Run time Control Array and Dynamic Form Generation
I have already got 25-30 forms in my project.i wasn't intrested in adding
extra form because these generated forms were only useful for moment and i am
not gng to use it anywhere further.That's why I thought of creating it
dynamically with the reuired components.By the way I implemented it the way
you told.
Thanks for your help.
Quote:


> > Hi,
> > Let me explain you what I want to accomplish.
> > i am creating forms at run time depending upon user's selection.Each
> > form has one command button and one MODI control.MODI control
> > displays .Tiff formatted images in it.But it's too small.So I want to
> > zoom it so that user can see it in full screen view.For zoom
> > purpose,I have added command button on each form.So ,when user cliks
> > on any so-called generated form's command button,MODI control on that
> > form should zoom itself.For that I want to handle clik event of
> > cliked command button and do zooming stuff.But I am only getting
> > click event of last generated form's command button.But I want it for
> >   any command button on any generated form. Your suggested approaches
> > are excellent.But I guess I would work with
> > static forms and controls.If you have any suggestions for above
> > mentioned criteria then pls help me out.
> > Thanks for your time and help.

> How do you create dynamic form instances at runtime?
> And why do you need to create dynamically buttons also?

> If each dynamic form had the same controls set, you could design a
> "template" form (say frmTemplate), placing on it any button and controls you
> like, e.g. cmdZoom.
> Of course, the template form should handle its own controls' events
> (cmdZoom_Click).

> So, when you're creating form at runtime, you have nothing else to do but
> create template instances:
> Set d_form(i) = New frmTemplate

> Since each instance of frmTemplate has its own controls set and events, you
> don't even have to worry about catching buttons clicks in the "caller"
> object.

> Raf



Sun, 19 Dec 2010 02:54:02 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. run-time forms generation

2. How can i put elements in a dynamic array during run time

3. Dynamic form generation

4. Creating controls in a control array at run-time

5. How to put a control inside a DataReport Dynamic in RUN-TIME

6. Dynamic Create Control at Run Time

7. Get handler of Dynamic controls created in run time

8. VB6, Run-Time Properties and Creating Dynamic Controls.

9. Get handler of dynamic control created in run time

10. Dynamic PDF Report Generation Control

11. A better way for dynamic form sizing based upon control array

12. Run-time code generation/evaluation in VB?

 

 
Powered by phpBB® Forum Software