Page 1 of 1
TWBrowse GoLeft() [Solved]
Posted: Fri Mar 09, 2007 8:55 am
by Enrico Maria Giordano
This is the sample:
Code: Select all
#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
Posted: Fri Mar 09, 2007 5:56 pm
by James Bott
Enrico,
I confirm it with Aug 2006 build. I'm surprized nobody has reported it sooner.
James
Posted: Fri Mar 09, 2007 7:17 pm
by Antonio Linares
This seems as a possible fix:
Code: Select all
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():
Code: Select all
...
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 ?
Posted: Fri Mar 09, 2007 11:09 pm
by Enrico Maria Giordano
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
Posted: Sat Mar 10, 2007 7:04 am
by Antonio Linares
Enrico,
Horizontal scrollbar updated:
Code: Select all
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 )
Posted: Sat Mar 10, 2007 8:29 am
by Enrico Maria Giordano
Perfect for me, thank you!
EMG
Posted: Mon Mar 12, 2007 5:53 pm
by Enrico Maria Giordano
Unfortunately there is still a bug:
Code: Select all
#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
Posted: Mon Mar 12, 2007 9:04 pm
by Antonio Linares
Enrico,
It is a side effect of the latest change. This seems to fix it:
Code: Select all
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 )
Posted: Mon Mar 12, 2007 9:50 pm
by Enrico Maria Giordano
Thank you.
EMG
Posted: Wed Mar 14, 2007 11:25 am
by Enrico Maria Giordano
Sorry, one more bug:
Code: Select all
#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
Posted: Sat Jul 26, 2008 10:38 am
by Enrico Maria Giordano
Any news?
EMG
Posted: Sun Jul 27, 2008 5:51 am
by Antonio Linares
Enrico,
Fixed. This code seems the right one:
Code: Select all
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:
Code: Select all
#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
Posted: Sun Jul 27, 2008 1:49 pm
by Enrico Maria Giordano
Many thanks!
EMG