TWindow metodo SaveState, RestoreState.

Post Reply
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

TWindow metodo SaveState, RestoreState.

Post 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.
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TWindow metodo SaveState, RestoreState.

Post 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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: TWindow metodo SaveState, RestoreState.

Post by jvtecheto »

If possible implement method for save xbrowse, columns, etc.?

Thanks for your support.

José.

Enviado desde mi ONE A2003 mediante Tapatalk
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TWindow metodo SaveState, RestoreState.

Post 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" } )
Regards

G. N. Rao.
Hyderabad, India
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: TWindow metodo SaveState, RestoreState.

Post by jvtecheto »

Awesome.

Fivewin is powerful.

Regards.

José.



Enviado desde mi ONE A2003 mediante Tapatalk
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
Compuin
Posts: 1017
Joined: Tue Dec 28, 2010 1:29 pm

Re: TWindow metodo SaveState, RestoreState.

Post 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 ?
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TWindow metodo SaveState, RestoreState.

Post 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
 
Regards

G. N. Rao.
Hyderabad, India
Compuin
Posts: 1017
Joined: Tue Dec 28, 2010 1:29 pm

Re: TWindow metodo SaveState, RestoreState.

Post 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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: TWindow metodo SaveState, RestoreState.

Post 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"
Regards

G. N. Rao.
Hyderabad, India
Compuin
Posts: 1017
Joined: Tue Dec 28, 2010 1:29 pm

Re: TWindow metodo SaveState, RestoreState.

Post 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
User avatar
jvtecheto
Posts: 357
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: TWindow metodo SaveState, RestoreState.

Post 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.
Fwh 19.06 32 bits + Harbour 3.2dev(r2011030937)+ Borland 7.4 + FivEdit
Post Reply