[Gambas-user] Settings with VSplit control

richard terry rterry at ...1946...
Sun Dec 12 22:11:19 CET 2010


On Monday 13 December 2010 01:25:10 Phạm Quang Dương wrote:

My code is used in probably hundreds of splits all over my program and works 
100%. of the time.

I'd never ever try and re-size forms or controls using the re-size event - let 
the properties of the forms/controls do that for you, combined with the 
Settings file.

Regards

Richard

> OK, thank you all.
> 
> @Terry: your code is like mine. It can not restore VSplit layout. I think
> problem from Form_Open and Form_Resize.
> 
> So I did:
> 
> SUB Form_Open()
> Dim i as Integer
> Settings.Read(ME.Window)
> i = Val(Settings["Group/key"])
> vsplit1.Layout = i & "," & (vsplit1.Height - i)
> END
> 
> SUB Form_Resize()
> ' Resize FMain components including vsplit1 to fit form
> END
> 
> PUBLIC SUB Form_Close()
> DIM a AS String[]
> a = Split(vsplit1.Layout, ",")
> Settings["Group/key"] = a[0]
> Settings.Write(ME.Window)
> END
> 
> It works better :)
> 
> 2010/12/12 richard terry <rterry at ...1946...>
> 
> > Simple sample code:
> >
> > Public sub Save_Settings()
> >      Settings["Your_Section_Name/HSplit_Main.Layout"] =
> > HSplit_Main.Layout end
> >
> > to restore this:
> >
> > Public Sub Settings_Load()
> > HSplit_Main.Layout =
> > Settings["Your_Section_Name/HSplit_Main.Layout"] = HSplit_Main.Layout
> >
> > End
> >
> > BTW settings is located usually in:
> >
> > /home/user/.config/gambas3/your_app_name.conf
> >
> > eg /home/richard/ etc
> >
> > Regards
> >
> > Richard
> >
> > On Sunday 12 December 2010 12:15:27 Benoît Minisini wrote:
> > > > Hi,
> > > >
> > > > How to save the layout of VSplit?
> > > > I tried:
> > > >
> > > > SUB Form_Open()
> > > > vsplit1.settings = Settings["Group/Key"];
> > > > PRINT Settings["Group/Key"] ' (1)
> > > > PRINT vsplit1.settings ' (2)
> > > > END
> > > >
> > > > Of course
> > > >
> > > > SUB Form_Close()
> > > > Settings["Group/Key"] = vsplit1.settings
> > > > END
> > > >
> > > > In running, (1) and (2) are different, all numbers in (2) are smaller
> > > > than (1). After some running, numbers in (2) decrease.
> > > >
> > > > I tried Settings.Read(vsplit1.window) too but I think that it saves
> > > > its location and size, not its content layout.
> > > >
> > > > Gambas 2.22.
> > > > Thanks!
> > >
> > > When writing to the splitter Settings property, the values of the
> > > layout are relatives. I mean that setting "1,2" or setting "2,4" has
> > > exactly
> >
> > the
> >
> > >  same result: 1/3 of the total size for the first pane, and 2/3 fot the
> > >  other one.
> > >
> > > When reading the Settings property, you normally get the true sizes. As
> > >  pixel sizes are integers, you don't get necessarily the same result.
> > >
> > > For example, if your splitter has 329 pixels to share, setting the
> > > layout to "1,2", or "2,4", or "200,400" will result in 110 pixels to
> > > the first pane and 219 pixels to the second pane. And so, when you will
> > > read the Settings property later, you will get "110,219".
> > >
> > > Does that explanation make things clearer?
> >
> > -------------------------------------------------------------------------
> >----- Oracle to DB2 Conversion Guide: Learn learn about native support for
> > PL/SQL,
> > new data types, scalar functions, improved concurrency, built-in
> > packages, OCI, SQL*Plus, data movement tools, best practices and more.
> > http://p.sf.net/sfu/oracle-sfdev2dev
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> ---------------------------------------------------------------------------
> --- Oracle to DB2 Conversion Guide: Learn learn about native support for
>  PL/SQL, new data types, scalar functions, improved concurrency, built-in
>  packages, OCI, SQL*Plus, data movement tools, best practices and more.
> http://p.sf.net/sfu/oracle-sfdev2dev
> _______________________________________________
> 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