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