Page 1 of 1

TWindow metodo SaveState, RestoreState.

Posted: Sat Jun 08, 2019 10:17 am
by jvtecheto
Hola:

Considero interesante estos 2 metodos, mi primera pregunta es si solo graban las coordenadas de la ventana, o si tambien si hay dentro un browse , columnas etc.

tambien me gustaria que se ampliara su funcionamiento para que leyeran de un archivo .INI ya que como tenemos muchas ventanas nos obliga a un fichero de texto por cada una.

Code: Select all

ACTIVATE WINDOW oWnd ;
ON INIT oWnd:RestoreState( MemoRead( "wndstate.txt" ) ) ;
VALID ( MemoWrit( "wndstate.txt", oWnd:SaveState() ), .t. )
 
Saludos.

Jose.

Re: TWindow metodo SaveState, RestoreState.

Posted: Sat Jun 08, 2019 3:19 pm
by nageswaragunupudi
oWnd:SaveState() returns a string of length 88 characters. You can also store in an INI file and restore from the INI file.

It stores the state of the window i.e., coordinates and the state. Safe to use even with multiple monitors.

Save the state of the window only but not any controls contained in it.

Re: TWindow metodo SaveState, RestoreState.

Posted: Sat Jun 08, 2019 8:34 pm
by jvtecheto
If possible implement method for save xbrowse, columns, etc.?

Thanks for your support.

José.

Enviado desde mi ONE A2003 mediante Tapatalk

Re: TWindow metodo SaveState, RestoreState.

Posted: Sun Jun 09, 2019 2:53 am
by nageswaragunupudi
oBrw:SaveState( [aData] ) --> cState
oBrw:RestoreState( cState )

These methods existed all the time.

By default, saves and restores :
RowHeight, column widths, display order of the columns, column show/hide status, group headers and column headers.

Additionally, the programmer can save and restore additional datas by specifying the data's names in an array as the parameter in the SaveState( aData )

Eg:
oBrw:SaveState( { "nMarqueeStyle", "cSortOrders" } )

Re: TWindow metodo SaveState, RestoreState.

Posted: Sun Jun 09, 2019 8:39 am
by jvtecheto
Awesome.

Fivewin is powerful.

Regards.

José.



Enviado desde mi ONE A2003 mediante Tapatalk

Re: TWindow metodo SaveState, RestoreState.

Posted: Mon Jun 24, 2019 5:20 pm
by Compuin
nageswaragunupudi wrote:oBrw:SaveState( [aData] ) --> cState
oBrw:RestoreState( cState )

These methods existed all the time.

By default, saves and restores :
RowHeight, column widths, display order of the columns, column show/hide status, group headers and column headers.

Additionally, the programmer can save and restore additional datas by specifying the data's names in an array as the parameter in the SaveState( aData )

Eg:
oBrw:SaveState( { "nMarqueeStyle", "cSortOrders" } )
Hello Mr Rao

May I have a sample ?

Re: TWindow metodo SaveState, RestoreState.

Posted: Tue Jun 25, 2019 1:15 am
by nageswaragunupudi

Code: Select all

#include "fivewin.ch"

function Main()

   local oWnd, oBrw, oIni

   INI oIni FILE "savestat.ini"

   USE CUSTOMER NEW SHARED

   DEFINE WINDOW oWnd
   @ 0,0 XBROWSE oBrw OF oWnd DATASOURCE Alias() AUTOCOLS ;
      CELL LINES NOBORDER
   oBrw:CreateFromCode()
   oWnd:oClient   := oBrw

   ACTIVATE WINDOW oWnd ;
      ON INIT ( oWnd:RestoreState( oIni:Get( "states", "window", "" ) ), ;
                oBrw:RestoreState( oIni:Get( "states", "browse", "" ) )  ) ;
      VALID   ( oIni:Set( "states", "window", oWnd:SaveState() ), ;
                oIni:Set( "states", "browse", oBrw:SaveState() ), ;
                .T. )

return nil
 

Re: TWindow metodo SaveState, RestoreState.

Posted: Tue Jun 25, 2019 1:41 am
by Compuin
nageswaragunupudi wrote:

Code: Select all

#include "fivewin.ch"

function Main()

   local oWnd, oBrw, oIni

   INI oIni FILE "savestat.ini"

   USE CUSTOMER NEW SHARED

   DEFINE WINDOW oWnd
   @ 0,0 XBROWSE oBrw OF oWnd DATASOURCE Alias() AUTOCOLS ;
      CELL LINES NOBORDER
   oBrw:CreateFromCode()
   oWnd:oClient   := oBrw

   ACTIVATE WINDOW oWnd ;
      ON INIT ( oWnd:RestoreState( oIni:Get( "states", "window", "" ) ), ;
                oBrw:RestoreState( oIni:Get( "states", "browse", "" ) )  ) ;
      VALID   ( oIni:Set( "states", "window", oWnd:SaveState() ), ;
                oIni:Set( "states", "browse", oBrw:SaveState() ), ;
                .T. )

return nil
 
Thanks, but is not creating any .ini

Re: TWindow metodo SaveState, RestoreState.

Posted: Tue Jun 25, 2019 3:53 am
by nageswaragunupudi
but is not creating any .ini
When we do not specify path for ini file, the ini file is created in and read from the user's appdata folder. This way different users can have their own ini files. Please search appdata folder.

If you want to create the ini file in the exe folder, please specify the name as ".\savestat.ini"

Re: TWindow metodo SaveState, RestoreState.

Posted: Tue Jun 25, 2019 4:02 am
by Compuin
nageswaragunupudi wrote:
but is not creating any .ini
When we do not specify path for ini file, the ini file is created in and read from the user's appdata folder. This way different users can have their own ini files. Please search appdata folder.

If you want to create the ini file in the exe folder, please specify the name as ".\savestat.ini"
Now is working! Thanks

Re: TWindow metodo SaveState, RestoreState.

Posted: Sun Oct 27, 2019 8:29 pm
by jvtecheto
Hi Mr. Rao.

this code works perfectly

Code: Select all

oIni:Set( "states", "browse", oBrw:SaveState()
 
but this not save anything

Code: Select all

oIni:Set( "states", "window", oWnd:SaveState()
 
I use this function.

Code: Select all

FUNCTION SaveWinData( oWnd, oBrw,cAlias )

   LOCAL oIni

   INI oIni File cDirectApp + "\OBRAS.INI"
   oIni:Set( cAlias, "window", oWnd:SaveState() )   
   oIni:Set( cAlias, "browse", oBrw:SaveState() )
    
  
RETURN NIL
 
and use it in VALID (SaveWinData(oWndObr,oBrw,cAlias) .T.)
[Obr]
window=
browse=XS1:{{"_nCreationOrders",{1,2,3,4}},{"_nRowHeight",21},{"_nWidths",{72.54,132.99,342.47,326.43}},{"_lHides",{.F.,.F.,.F.,.F.}},{"_cGrpHdrs",{,,,}},{"_cHeaders",{"CODIGO","C.I.F.","NOMBRE","DIRECCION"}}}
what am i doing wrong?

thanks in advance.

Jose.