FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour BUG xBrowse savestate, restorestate
Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
BUG xBrowse savestate, restorestate
Posted: Mon Dec 01, 2008 06:01 PM
Tengo el siguiente problema:


#include "fivewin.ch"
#include "xbrowse.ch"

function Main2()

   local oDlg, oBrw, cSaveState, cPath := "c:\"

  cSaveState := GETPVPROFSTRING( "BrowseArray", "SaveState", "", cPath + "prueba.ini" )
  msginfo( cSaveState )

   DEFINE DIALOG oDlg SIZE 600, 200

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY { { "uno","dos","tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez" } } AUTOCOLS
      
   oBrw:CreateFromCode()

   oBrw:bKeyDown = { || oDlg:SetText( Str( oBrw:nColSel ) ) }  
      
   ACTIVATE DIALOG oDlg CENTER ON INIT ( IIF( !EMPTY( cSaveState ), oBrw:RestoreState( cSaveState ), "" ), oDlg:oClient := oBrw, oDlg:Resize() );
                        VALID ( cSaveState := oBrw:savestate(), msginfo( cSaveState), WritePProString( "BrowseArray", "SaveState", cSaveState, cPath + "prueba.ini" ), .t. )


return nil



Si pongo la columna numero diez entre la 6 y la 7, al hacer el restorestate me cambia el orden de las columnas 7, 8 y 9, alguna idea?


gracias
Pedro Gonzalez
Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
BUG xBrowse savestate, restorestate
Posted: Wed Dec 03, 2008 11:46 AM

Antonio,

Es un problema que da fastidio a mis clientes, ya que todo mi programa ahora usa xbrowse, y salva/recupera las posiciones de cada columna.
Se logra entender cual es el problema o pongo imagenes?

gracias

Pedro Gonzalez
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
BUG xBrowse savestate, restorestate
Posted: Wed Dec 03, 2008 02:39 PM

siempre una imagen habla mas que mil palabras... :wink:

Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
BUG xBrowse savestate, restorestate
Posted: Wed Dec 03, 2008 03:59 PM
Abro la ventana con el browse:





Cambio la columna 10 y la meto entra la 6 y la 7:



Cierro el browse, salvo en el archivo .ini y luego re-abro el browse:



El orden deberia ser: 1,2,3,4,5,6,10,7,8,9

En vez, el orden es: 1,2,3,4,5,6,10,9,8,7

Ahora deberia ser mas claro.

Saludos
Pedro Gonzalez
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
BUG xBrowse savestate, restorestate
Posted: Thu Dec 04, 2008 05:12 PM
cambia el metodo RestoreState( cState )
por este... espero se solucione tu problema
METHOD RestoreState( cState ) CLASS TXBrowse

   local oCol
   local aMoved, aNaturalOrder
   local cCol
   local nLen, nOrder, nWidth, nFor, nAt, nHeight
   local lHide,cHeader,j

   if Empty( cState )
      return nil
   endif

   aMoved := {}
   aNaturalOrder := {}
   nLen   := Len( ::aCols )

   nHeight := Val(StrToken( cState, 1, ";" ) )

   if Empty( ::nRowHeight )
      return nil
   endif

   // Check integrity

   for nFor := 1 to nLen
      cCol := StrToken( cState, nFor + 1, ";" )
      if Empty( cCol )
         return nil
      endif
      aadd( aNaturalOrder, nFor )
   next

   ::nRowHeight := nHeight

   for nFor := 1 to nLen
      cCol   := StrToken( cState, nFor + 1, ";" )
      nOrder := Val( StrToken( cCol, 1, ":" ) )
      nWidth := Val( StrToken( cCol, 2, ":" ) )
      cHeader :=  StrToken( cCol, 3, ":" )
      lHide  := ( AllTrim( StrToken( cCol, 4, ":" ) ) == "H" )
      nAt := Ascan( ::aCols, {|v| v:nCreationOrder == nOrder } )
      if nAt > 0
         oCol := ::aCols[ nAt ]
         oCol:lHide  := lHide
         oCol:nWidth := nWidth
         oCol:cHeader := cHeader
      endif
      if nOrder != nFor  
      	if nOrder != aNaturalOrder[ nFor ] .and. ( nAt := Ascan( aNaturalOrder, nOrder ) ) != 0 
         ::SwapCols( nFor, nAt, .f. )         
         aNaturalOrder[ nFor ]:= nOrder
         aNaturalOrder[ nAt ]:= nFor
        endif
      endif      	
   next

   ::GetDisplayCols()
   ::Super:Refresh()

return nil
Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
BUG xBrowse savestate, restorestate
Posted: Thu Dec 04, 2008 05:17 PM

Daniel,

muchas gracias, lo acabo de probar y funciona :-)

Ahora voy a fijarme cuales son las modificaciones que tu hiciste, serían de proponer a Antonio, porque es un bug en la clase original.

Saludos y nuevamente gracias

Pedro Gonzalez
Posts: 383
Joined: Tue Oct 11, 2005 01:01 PM
BUG xBrowse savestate, restorestate
Posted: Thu Dec 04, 2008 05:20 PM

Daniel,

visto el código escrito me quedó clarísimo.

ahora lo pruebo mas a fondo, pero te diría que quedó perfecto.

saludos

Pedro Gonzalez
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
BUG xBrowse savestate, restorestate
Posted: Thu Dec 04, 2008 06:39 PM

siempre a la orden cualquier cosa mi messenger es danielgarciagil@cantv.net

Continue the discussion