[Gambas-user] Crssed interexchange between forms

Richard richard.j.walker at ...247...
Sat Mar 29 19:29:19 CET 2008


Hi Stefano, 

The interesting thing is that Pino's code works too. Is there a reason why it 
is "wrong" to instantiate a form created in the GUI? (Apart from the fact 
that at first sight it looks to be unneccessary)

Richard

On Saturday 29 Mar 2008 18:22, Stefano Palmeri wrote:
> Alle 18:56, sabato 29 marzo 2008, Pino Zollo ha scritto:
> > Alle 09:18, sabato 29 marzo 2008, hai scritto:
> > Hi Richard and Rob
> > Thanks for your answers and suggestion....
> > Both of your solutions do not work....I do not know why.
> >
> > So I made an example program to show you the double problem.
> > You can download it form http://www.qsl.net/zp4kfx/xcross-0.0.1.tar.gz
> >
> > This program opens 3 forms: Fmain, FormA and FormB.
> > On my computer FormA can send a value to Fmain end execute a PULIC SUB of
> > FMain too, but not on FormB.
> > The symetric  for FormB
> > FMain can not send values to FormA or FormB and nither execute PUBLIC
> > SUBs in both.
> > No errors are displayed.
> >
> > I did set public both module symbols and control forms.
> >
> > Maybe there is something else that I do not have understood.
> >
> > Thanks for your help
> > Regards
> > Pino
> >
> > > As an alternative to Rob's suggestion that you make all form controls
> > > public (which should work) you might prefer to create public methods on
> > > your forms which will take a parameter from the calling form code and
> > > store the value in a now local form control property.
> > >
> > > For example; if on frmCW you have
> > >
> > > PUBLIC SUB Write_CWcall_text(calltext as string)
> > > 	CWCall.text = calltext
> > > END SUB
> > >
> > > then on FMain you would write
> > >
> > > 	 IF cw_on THEN FrmCW.Write_CWcall_text(Call.Text)
> > >
> > > That should also do the trick and preserve flexibility. If form
> > > controls are public then you can write directly to them from ANYWHERE.
> > > What if you decide to change the control from a text box to a value
> > > box? You would have to go through all your code and change all the
> > > writes and reads involving the changed control.
> > >
> > > If instead you do it as I suggest, then you only need to change the
> > > access methods for READ and WRITE in one place. Much easier, yes?
> > >
> > > Richard
> > >
> > > On Friday 28 Mar 2008 18:04, Pino Zollo wrote:
> > > > I am developing a program in GAMBAS2 2.0
> > > >
> > > > How can I pass information between one form and another ?
> > > >
> > > > In my program there are 3 forms....FMain, FrmCW e FCluster.
> > > >
> > > > >From the class of FrmCW (or of Fcluster) I can write a value in
> > > >
> > > > FMain.variabile....
> > > > But nither from FMain and from FCluster can write variabes in
> > > > FrmCW.somevariable.
> > > >
> > > > It means that the class  of FMain can not send values to the
> > > > variables of other classes , nither a class (not FMain) can send
> > > > values to other classes which are not FMain ...Why this ?
> > > >
> > > > It seems a big limitation.
> > > > For instance...in FMain the instruction:
> > > >
> > > >       IF cw_on THEN FrmCW.CWCall.text = Call.Text
> > > >
> > > > Simply does nothing...nither gives error.
> > > >
> > > > In the class of FCluster
> > > >   FMain.Call.Text = GridSpot[GridSpot.row, 0].Text ' <-- this is ok
> > > >   IF FMain.cw_on THEN FrmCW.CWCall.text = GridSpot[GridSpot.row,
> > > > 0].Text ' <--
> > > >
> > > > The first instruction works, but the second does nothing.
> > > >
> > > >  Why ?
> > > >
> > > > Is there some trick or workaround ?
> > > >
> > > > For the same reason, I guess,  it does not even work the example in
> > > > suggestion #11.
> > > >
> > > > the instruction
> > > >
> > > > hSuperControl.Move(8, 8, 128, 64)
> > > >
> > > > if given into the FMain class gives error..."Not enough parameters"
> > > >
> > > > >From a class not-FMain I can call SUBs of FMain, but not viceversa
> > > >
> > > > Equally from a class not-FMain I can not call SUBs of not-FMain
> > > >
> > > > Thanks for any help
> > > >
> > > > Pino    pinozollo at ...626...
>
> I opened your project. The FMain Form_Open() function is wrong:
> Here it is the right way:
>
> PUBLIC SUB Form_Open()
>
>   ' DIM Frma AS FormA
>   ' DIM FrmB AS FormB
>     ME.Center
>     ME.Show
>     ' Frma = NEW FormA
>     ' Frma.Visible = TRUE
>     '
>     ' FrmB = NEW FormB
>     ' FrmB.Visible = TRUE
>
>     FormA.Show
>     Formb.Show
>
> END
>
> I commented out the wrong code.
>
> Bye,
>
> Stefano
>
> > > > ---------------------------------------------------------------------
> > > >-- -- Check out the new SourceForge.net Marketplace.
> > > > It's the best place to buy or sell services for
> > > > just about anything Open Source.
> > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/mark
> > > >et pl ac e _______________________________________________
> > > > Gambas-user mailing list
> > > > Gambas-user at lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> > -------------------------------------------------------------------------
> > Check out the new SourceForge.net Marketplace.
> > It's the best place to buy or sell services for
> > just about anything Open Source.
> > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketpl
> >ac e _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplac
>e _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list