TWindow metodo SaveState, RestoreState.

TWindow metodo SaveState, RestoreState.

Postby jvtecheto » 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: Select all  Expand view  RUN

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

Re: TWindow metodo SaveState, RestoreState.

Postby nageswaragunupudi » Sat Jun 08, 2019 3: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
User avatar
nageswaragunupudi
 
Posts: 10663
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TWindow metodo SaveState, RestoreState.

Postby jvtecheto » Sat Jun 08, 2019 8: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
User avatar
jvtecheto
 
Posts: 600
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: TWindow metodo SaveState, RestoreState.

Postby nageswaragunupudi » Sun Jun 09, 2019 2: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
User avatar
nageswaragunupudi
 
Posts: 10663
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TWindow metodo SaveState, RestoreState.

Postby jvtecheto » Sun Jun 09, 2019 8: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
User avatar
jvtecheto
 
Posts: 600
Joined: Mon Mar 04, 2013 4:32 pm
Location: Spain

Re: TWindow metodo SaveState, RestoreState.

Postby Compuin » Mon Jun 24, 2019 5: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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: TWindow metodo SaveState, RestoreState.

Postby nageswaragunupudi » Tue Jun 25, 2019 1:15 am

Code: Select all  Expand view  RUN
#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
User avatar
nageswaragunupudi
 
Posts: 10663
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TWindow metodo SaveState, RestoreState.

Postby Compuin » Tue Jun 25, 2019 1:41 am

nageswaragunupudi wrote:
Code: Select all  Expand view  RUN
#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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: TWindow metodo SaveState, RestoreState.

Postby nageswaragunupudi » Tue Jun 25, 2019 3: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
User avatar
nageswaragunupudi
 
Posts: 10663
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TWindow metodo SaveState, RestoreState.

Postby Compuin » Tue Jun 25, 2019 4: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 20.12
Hbmk2 32/64 Bits (Build 19.29.30133)
Microsoft Visual C 32 Bits
MySql 8.0.24 32/64 Bits
VS Code
Compuin
 
Posts: 1214
Joined: Tue Dec 28, 2010 1:29 pm
Location: Quebec, Canada

Re: TWindow metodo SaveState, RestoreState.

Postby jvtecheto » Sun Oct 27, 2019 8:29 pm

Hi Mr. Rao.

this code works perfectly

Code: Select all  Expand view  RUN

oIni:Set( "states", "browse", oBrw:SaveState()
 


but this not save anything

Code: Select all  Expand view  RUN

oIni:Set( "states", "window", oWnd:SaveState()
 


I use this function.

Code: Select all  Expand view  RUN

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


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: karinha and 59 guests