FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour TWindow metodo SaveState, RestoreState.
Posts: 607
Joined: Mon Mar 04, 2013 04:32 PM
TWindow metodo SaveState, RestoreState.
Posted: Sat Jun 08, 2019 10:17 AM
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 (fw): Select all Collapse
ACTIVATE WINDOW oWnd ;
ON INIT oWnd:RestoreState( MemoRead( "wndstate.txt" ) ) ;
VALID ( MemoWrit( "wndstate.txt", oWnd:SaveState() ), .t. )


Saludos.

Jose.
Fwh 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TWindow metodo SaveState, RestoreState.
Posted: Sat Jun 08, 2019 03:19 PM

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
Posts: 607
Joined: Mon Mar 04, 2013 04:32 PM
Re: TWindow metodo SaveState, RestoreState.
Posted: Sat Jun 08, 2019 08:34 PM

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

Thanks for your support.

José.

Enviado desde mi ONE A2003 mediante Tapatalk

Fwh 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TWindow metodo SaveState, RestoreState.
Posted: Sun Jun 09, 2019 02:53 AM

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
Posts: 607
Joined: Mon Mar 04, 2013 04:32 PM
Re: TWindow metodo SaveState, RestoreState.
Posted: Sun Jun 09, 2019 08:39 AM

Awesome.

Fivewin is powerful.

Regards.

José.

Enviado desde mi ONE A2003 mediante Tapatalk

Fwh 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: TWindow metodo SaveState, RestoreState.
Posted: Mon Jun 24, 2019 05:20 PM
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 ?

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TWindow metodo SaveState, RestoreState.
Posted: Tue Jun 25, 2019 01:15 AM
Code (fw): Select all Collapse
#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
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: TWindow metodo SaveState, RestoreState.
Posted: Tue Jun 25, 2019 01:41 AM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
#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

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TWindow metodo SaveState, RestoreState.
Posted: Tue Jun 25, 2019 03:53 AM
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
Posts: 1276
Joined: Tue Dec 28, 2010 01:29 PM
Re: TWindow metodo SaveState, RestoreState.
Posted: Tue Jun 25, 2019 04:02 AM
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

FWH 25.12

Harbour/Hbmk2

Microsoft Visual C++

MySql 8.0

Antigravity

Posts: 607
Joined: Mon Mar 04, 2013 04:32 PM
Re: TWindow metodo SaveState, RestoreState.
Posted: Sun Oct 27, 2019 08:29 PM
Hi Mr. Rao.

this code works perfectly

Code (fw): Select all Collapse
oIni:Set( "states", "browse", oBrw:SaveState()


but this not save anything

Code (fw): Select all Collapse
oIni:Set( "states", "window", oWnd:SaveState()


I use this function.

Code (fw): Select all Collapse
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 24.07 64 bits + Harbour 64 bits 3.2dev(r2407221137) + MSVC64

Continue the discussion