FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Bugs report & fixes / Informe de errores y arreglos TWBrowse GoLeft() [Solved]
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
TWBrowse GoLeft() [Solved]
Posted: Fri Mar 09, 2007 08:55 AM
This is the sample:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oBrw

    USE TEST

    DEFINE WINDOW oWnd

    @ 0, 0 LISTBOX oBrw FIELDS

    oBrw:lCellStyle = .T.

    oWnd:oClient = oBrw

    ACTIVATE WINDOW oWnd;
             MAXIMIZED

    CLOSE

    RETURN NIL


Try to:

- move the hilight to a column near the right side of the browse

- restore the window (click the button near the right-top X)

- move the now invisible hilight to the left

You should get an error.

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
TWBrowse GoLeft() [Solved]
Posted: Fri Mar 09, 2007 05:56 PM

Enrico,

I confirm it with Aug 2006 build. I'm surprized nobody has reported it sooner.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
TWBrowse GoLeft() [Solved]
Posted: Fri Mar 09, 2007 07:17 PM
This seems as a possible fix:
METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TWBrowse

   local nTotalSize := 0

   ::nRowPos = Min( ::nRowPos, Max( ::nRowCount(), 1 ) )
   ::nColAct = Min( ::nColAct, AScan( ::GetColSizes(),;
                                      { | nSize | nTotalSize += nSize,;
                                      nWidth < nTotalSize }, ::nColPos ) )

return Super:ReSize( nSizeType, nWidth, nHeight )

and in function wbrwline():
   ...
   nColPos = Max( nColPos, 1 )  // new!

   for n := nColPos to Len( aValues )
      nLeft   = nColStart + 1
      nRight  = Min( nColStart := ( nLeft + aColSizes[ n ] - 1 ), nWidth )
      if nLeft > nWidth
         exit
      endif
      if n >= Len( aValues ) // changed!
         nRight = nWidth
      endif
      ...

though is this the desirable behavior ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
TWBrowse GoLeft() [Solved]
Posted: Fri Mar 09, 2007 11:09 PM
Antonio Linares wrote:This seems as a possible fix:


Thank you.

Antonio Linares wrote:though is this the desirable behavior ?


Yes, it is similar to the vertical resize behavior. But there is one more problem: the horizontal scrollbar is not correctly updated. Can you fix that too?

EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
TWBrowse GoLeft() [Solved]
Posted: Sat Mar 10, 2007 07:04 AM
Enrico,

Horizontal scrollbar updated:
METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TWBrowse

   local nTotalSize := 0

   ::nRowPos = Min( ::nRowPos, Max( ::nRowCount(), 1 ) )
   ::nColAct = Min( ::nColAct, AScan( ::GetColSizes(),;
                                      { | nSize | nTotalSize += nSize,;
                                      nWidth < nTotalSize }, ::nColPos ) )
   if ::oHScroll != nil
      ::oHScroll:SetPos( ::nColAct )
   endif

return Super:ReSize( nSizeType, nWidth, nHeight )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
TWBrowse GoLeft() [Solved]
Posted: Sat Mar 10, 2007 08:29 AM

Perfect for me, thank you!

EMG

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
TWBrowse GoLeft() [Solved]
Posted: Mon Mar 12, 2007 05:53 PM
Unfortunately there is still a bug:

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oBrw

    DBCREATE( "BUGTEST", { { "TEST1", "C", 10, 0 },;
                           { "TEST2", "C", 10, 0 } } )

    USE BUGTEST

    APPEND BLANK

    DEFINE WINDOW oWnd

    @ 0, 0 LISTBOX oBrw FIELDS

    oBrw:lCellStyle = .T.

    oWnd:oClient = oBrw

    ACTIVATE WINDOW oWnd;
             MAXIMIZED

    CLOSE

    RETURN NIL


No cell is selected.

EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
TWBrowse GoLeft() [Solved]
Posted: Mon Mar 12, 2007 09:04 PM
Enrico,

It is a side effect of the latest change. This seems to fix it:
METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TWBrowse

   local nTotalSize := 0

   ::nRowPos = Min( ::nRowPos, Max( ::nRowCount(), 1 ) )
   ::nColAct = Min( ::nColAct, AScan( ::GetColSizes(),;
                                      { | nSize | nTotalSize += nSize,;
                                      nWidth < nTotalSize }, ::nColPos ) )
   ::nColAct = Max( ::nColAct, 1 )
                                      
   if ::oHScroll != nil
      ::oHScroll:SetPos( ::nColAct )
   endif

return Super:ReSize( nSizeType, nWidth, nHeight )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
TWBrowse GoLeft() [Solved]
Posted: Mon Mar 12, 2007 09:50 PM

Thank you.

EMG

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
TWBrowse GoLeft() [Solved]
Posted: Wed Mar 14, 2007 11:25 AM
Sorry, one more bug:

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oBrw

    DBCREATE( "BUGTEST", { { "TEST1", "C", 10, 0 },;
                           { "TEST2", "C", 10, 0 } } )

    USE BUGTEST

    APPEND BLANK

    DEFINE WINDOW oWnd

    @ 0, 0 LISTBOX oBrw FIELDS

    oBrw:lCellStyle = .T.

    oWnd:oClient = oBrw

    ACTIVATE WINDOW oWnd;
             MAXIMIZED

    CLOSE

    RETURN NIL


Select the second column and the resize the window: the first column will be selected back.

EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
TWBrowse GoLeft() [Solved]
Posted: Sun Jul 27, 2008 05:51 AM
Enrico,

Fixed. This code seems the right one:
METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TWBrowse

   local n, nTotalSize := 0, aSizes := ::GetColSizes()

   ::nRowPos = Min( ::nRowPos, Max( ::nRowCount(), 1 ) )
   
   n = Max( ::nColPos, 1 )
   while nTotalSize < nWidth .and. n <= Len( aSizes )
      nTotalSize += aSizes[ n++ ]
   end
   ::nColAct = Min( --n, ::nColAct )
                                      
   if ::oHScroll != nil
      ::oHScroll:SetPos( ::nColAct )
   endif

return Super:ReSize( nSizeType, nWidth, nHeight )

Please modify your example as follows and shrink the window and you will see how the selected cell is changed to the last visible one:
#include "Fivewin.ch" 


FUNCTION MAIN() 

    LOCAL oWnd, oBrw 

    DBCREATE( "BUGTEST", { { "TEST1", "C", 10, 0 },; 
                           { "TEST2", "C", 10, 0 },;
                           { "TEST3", "C", 10, 0 },;
                           { "TEST4", "C", 10, 0 } } ) 

    USE BUGTEST 

    APPEND BLANK 

    DEFINE WINDOW oWnd 

    @ 0, 0 LISTBOX oBrw FIELDS 

    oBrw:lCellStyle = .T. 

    oWnd:oClient = oBrw 

    ACTIVATE WINDOW oWnd 
           

    CLOSE 

    RETURN NIL
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
TWBrowse GoLeft() [Solved]
Posted: Sun Jul 27, 2008 01:49 PM

Many thanks! :-)

EMG

Continue the discussion