changing the column sequence, RestoreState() results in a wrong column <-> data relation!
Original browse:
Browse with changed column sequence:
Browse with wrong relations after two "SaveState() - RestoreState()" iterations:
Sample:
- Code: Select all Expand view
- #include "fivewin.ch"
#include "xbrowse.ch"
#include "FILEIO.CH"
function Main()
local oWnd, oBrw, oCol
LOCAL cState := ""
LOCAL aState
LOCAL i
LOCAL nFileHandle
REQUEST DBFCDX
USE RSTRSTT
INDEX ON Field->Prmtr_txt TO RSTRSTT
SET ORDER TO "RSTRSTT"
IF FILE( "rstrstts.txt" )
nFileHandle := FOpen( "rstrstts.txt", FO_READ )
FSeek( nFileHandle, 0, FS_SET )
HB_FReadLine( nFileHandle, @cState )
FClose( nFileHandle )
ENDIF
GO TOP
DEFINE WINDOW oWnd TITLE "Test RestoreState() FWH 1010"
@ 0, 0 XBROWSE oBrw OF oWnd LINES CELL
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
oBrw:CreateFromCode()
aState := ARead( HexToStr( SubStr( cState, 5 ) ) )
oBrw:RestoreState( cState )
FOR each oCol in oBrw:aCols
IF oCol:nWidth > 500
oCol:nWidth := 150
ENDIF
NEXT
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd VALID ( cState := oBrw:SaveState(), .T. )
nFileHandle := FCreate( "rstrstts.txt", FO_EXCLUSIVE )
FWrite( nFileHandle, cState )
FClose( nFileHandle )
RETURN NIL