FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Para Antonio: xBrowse nFreeze (APORTE)
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Para Antonio: xBrowse nFreeze (APORTE)
Posted: Sun May 19, 2013 12:10 AM
Antonio.
Vista la necesidad de un colega, expuesta aquí en el foro, y, por supuesto, la mía propia, viewtopic.php?f=6&t=26312#p144716 , me he puesto a trabajar en una solución, la cual creo que he encontrado.

La he probado bastante y no me ha dado ninguna falla.
Ahora el Method GoLeft() Class TXBrowse, detecta si se está utilizando columnas congeladas, y se comporta como lo necesitamos. Si al avanzar hacia la derecha, se ocultan columnas por las congeladas, al regresar hacia la izquierda y llegar a la primer columna despues de la nFreezed y se continua avanzando hacia la izquierda, van apareciendo las ocultas, mientras el cursor se mantiene en la misma columna, hasta que aparece la No. 1 despues de las congeladas, y hasta entonces continua avanzando sobre las congeladas. Aqui el codigo original, y el modificado por tu servidor.

//----------------------------------------------------------------------------//
/*
METHOD GoLeft( lOffset, lRefresh ) CLASS TXBrowse

::CancelEdit()

if ::nMarqueeStyle == MARQSTYLE_NOMARQUEE .or. ( ::nMarqueeStyle >= MARQSTYLE_HIGHLROW .and. ::bClrRowFocus == nil )
lOffset := .t.
endif

DEFAULT lOffset := .f.,;
lRefresh := .t.

if ( !lOffset .and. ::IsDisplayPosVisible( ::nColSel - 1 ) ) .or. ;
( ::nColOffset == 1 .and. ::nColSel > 1 )
::nColSel--
if lRefresh
if ::FullPaint()
::Refresh( .t. )
else
::DrawLine( .t. )
endif
endif
elseif ::nColOffset > 1
::nColOffset--
::GetDisplayCols()
if lRefresh
::Refresh( ::FullPaint() )
endif
endif

if ::oHScroll != nil
::GoUp()
endif
::Change( .f. )

return nil
*/


Code (fw): Select all Collapse
//-----------------------------------------------------
//Method GoLeft() modified by Francisco J. Alegría P. - May 18, 2013
//------------------------------------------------------
METHOD GoLeft( lOffset, lRefresh )  CLASS TXBrowse
local oFirstCol

   ::CancelEdit()

   if ::nMarqueeStyle == MARQSTYLE_NOMARQUEE  .or. ( ::nMarqueeStyle >= MARQSTYLE_HIGHLROW .and. ::bClrRowFocus == nil ) ;
      .or. ::nFreeze > 0
      lOffset := .t.
   endif

   DEFAULT lOffset  := .f.,;
           lRefresh := .t.

IF !lOffset 

   if ( ::IsDisplayPosVisible( ::nColSel - 1 ) ) .or. ;
      ( ::nColOffset == 1 .and. ::nColSel > 1 )
      ::nColSel--
      if lRefresh
         if ::FullPaint()
            ::Super:Refresh( .t. )
         else
            ::DrawLine( .t. )
         endif
      endif
   elseif ::nColOffset > 1
      ::nColOffset--
      ::GetDisplayCols()
      if lRefresh
         ::Super:Refresh( ::FullPaint() )
      endif
   endif

ELSE

   if ::SelectedCol():nCreationOrder == 1
      return nil
   endif

   oFirstCol := if ( ::nFreeze > 0, ::aCols[::nFreeze+1], ::aCols[1] )

   if ::IsDisplayPosVisible( oFirstCol:nPos, .t. )
      ::nColSel--
      if lRefresh
         ::Super:Refresh( .t. )
      endif

   else
      ::nColSel--
      if lRefresh
         ::Super:Refresh( .t. )
      endif

      if ::nColSel == ::nFreeze
         ::GoRight()
         ::nColOffSet--
         ::GetDisplayCols()
         if lRefresh
            ::Super:Refresh( ::FullPaint() )
         endif
         if ::oHScroll != nil
            ::oHScroll:GoUp()
         endif
      endif
   endif

ENDIF

   if ::oHScroll != nil
      ::oHScroll:GoUp()
   endif
   ::Change( .f. )

return nil

Espero que sea de utilidad.
Saludos.
Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 593
Joined: Sat May 12, 2007 11:47 AM
Re: Para Antonio: xBrowse nFreeze (APORTE)
Posted: Sun May 19, 2013 03:02 PM
Francisco,

Muy bueno lo tuyo.

Lo probé en mi sistema y funciona bien en casi todos los casos.

Pero tengo un xBrowse de 5 columnas en el cual hago un freeze en la columna 5 (para que no se vaya del dialog por recursos al darle a la flechita derecha).

Ahí daba un error cuando se quería volver hacia la izquierda (le suma 1 a la columna cuando ::nFreeze > 0 y, justo el freeze está en la última columna del xBrowse).

Le hice una pequeña reforma a lo tuyo y pongo a tu consideración, acá me funciona correcto.

Code (fw): Select all Collapse
//  oFirstCol := if ( ::nFreeze > 0, ::aCols[::nFreeze+1], ::aCols[1] )

     oFirstCol := if ( ::nFreeze > 0 .and. ::nFreeze<len(::aCols), ::aCols[::nFreeze+1], ::aCols[1] )


Saludos.

Rolando :-)
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Para Antonio: xBrowse nFreeze (APORTE)
Posted: Sun May 19, 2013 08:19 PM
Rolando,
Es correcto. He integrado tu modificacion.
Code (fw): Select all Collapse
//-----------------------------------------------------
//Method GoLeft() modified by Francisco J. Alegría P. - May 18, 2013
//------------------------------------------------------
METHOD GoLeft( lOffset, lRefresh )  CLASS TXBrowse
local oFirstCol

   ::CancelEdit()

   if ::nMarqueeStyle == MARQSTYLE_NOMARQUEE  .or. ( ::nMarqueeStyle >= MARQSTYLE_HIGHLROW .and. ::bClrRowFocus == nil ) ;
      .or. ::nFreeze > 0
      lOffset := .t.
   endif

   DEFAULT lOffset  := .f.,;
           lRefresh := .t.

IF !lOffset 

   if ( ::IsDisplayPosVisible( ::nColSel - 1 ) ) .or. ;
      ( ::nColOffset == 1 .and. ::nColSel > 1 )
      ::nColSel--
      if lRefresh
         if ::FullPaint()
            ::Super:Refresh( .t. )
         else
            ::DrawLine( .t. )
         endif
      endif
   elseif ::nColOffset > 1
      ::nColOffset--
      ::GetDisplayCols()
      if lRefresh
         ::Super:Refresh( ::FullPaint() )
      endif
   endif

ELSE

   if ::SelectedCol():nCreationOrder == 1
      return nil
   endif

   //oFirstCol := if ( ::nFreeze > 0, ::aCols[::nFreeze+1], ::aCols[1] )
   oFirstCol := if ( ::nFreeze > 0 .and. ::nFreeze < len(::aCols), ::aCols[::nFreeze+1], ::aCols[1] )  //Rolando 

   if ::IsDisplayPosVisible( oFirstCol:nPos, .t. )
      ::nColSel--
      if lRefresh
         ::Super:Refresh( .t. )
      endif

   else
      ::nColSel--
      if lRefresh
         ::Super:Refresh( .t. )
      endif

      if ::nColSel == ::nFreeze
         ::GoRight()
         ::nColOffSet--
         ::GetDisplayCols()
         if lRefresh
            ::Super:Refresh( ::FullPaint() )
         endif
         if ::oHScroll != nil
            ::oHScroll:GoUp()
         endif
      endif
   endif

ENDIF

   if ::oHScroll != nil
      ::oHScroll:GoUp()
   endif
   ::Change( .f. )

return nil

Gracias por ayudarme a depurar el codigo.
Saludos.
Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Para Antonio: xBrowse nFreeze (APORTE)
Posted: Mon May 20, 2013 02:18 PM

Francisco, Rolando,

Incluido para el próximo build, muchas gracias! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 880
Joined: Fri Jan 12, 2007 08:35 PM
Re: Para Antonio: xBrowse nFreeze (APORTE)
Posted: Fri May 24, 2013 02:35 AM

Muy bueno :mrgreen:

Muchos tenquius :D

Saluditos :wink:

Que es mejor que programar? creo que nada :)
Atropellada pero aqui ando :P

I love Fivewin

séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Para Antonio: xBrowse nFreeze (APORTE)
Posted: Mon May 27, 2013 03:35 PM
Mr FranciscoA

To get what you want I suggest a very simple modification to the existing code.
I have inserted 3 lines of code. You can see below:

Code (fw): Select all Collapse
METHOD GoLeft( lOffset, lRefresh )  CLASS TXBrowse

   ::CancelEdit()

   if ::nMarqueeStyle == MARQSTYLE_NOMARQUEE  .or. ( ::nMarqueeStyle >= MARQSTYLE_HIGHLROW .and. ::bClrRowFocus == nil )
      lOffset := .t.
   endif

   DEFAULT lOffset  := .f., lRefresh := .t.

   // Begin insert new code
   if ::nFreeze > 0 .and. ::nColOffSet > 1 .and. ::nColSel == ::nFreeze + 1
      lOffset := .t.
   endif
   // end of inserted code

   if ( !lOffset .and. ::IsDisplayPosVisible( ::nColSel - 1 ) ) .or. ;
      ( ::nColOffset == 1 .and. ::nColSel > 1 )
      ::nColSel--
      if lRefresh
         if ::FullPaint()
            ::Super:Refresh( .t. )
         else
            ::DrawLine( .t. )
         endif
      endif
   elseif ::nColOffset > 1
      ::nColOffset--
      ::GetDisplayCols()
      if lRefresh
         ::Super:Refresh( ::FullPaint() )
      endif
   endif

   if ::oHScroll != nil
      ::oHScroll:GoUp()
   endif
   ::Change( .f. )

return nil

Can you please try this?
In my tests this is working satisfactorily.
Regards



G. N. Rao.

Hyderabad, India
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Para Antonio: xBrowse nFreeze (APORTE)
Posted: Tue May 28, 2013 01:40 AM

Mr nageswaragunupudi,
Yes, I've done some tests and your code is working fine for me. I modified mine.
Thank you for your attention.

Si, hice algunas pruebas y su código está bien, para mi. He cambiado el mio.
Gracias por su atención.

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql

Continue the discussion