please test this change the class
new data in txbrowse class
DATA bSelected
Change Method Select
METHOD Select( nOperation ) CLASS TXBrowse
local uBook, uCurRow, uOldRow, uTemp
local aTemp
local nAt, nLen
local lRefresh
if ::nMarqueeStyle != MARQSTYLE_HIGHLROWMS
return nil
endif
if VALTYPE ( Eval( ::bSelected, Self ) ) != "L" //daniel
msgalert( "Invalid CodeBlock ::bSelected", "FiveWin, Class TXBrowse" ) //daniel
return nil //daniel
endif //daniel
DEFAULT nOperation := 1
do case
case nOperation == 0 // delete all
if Len( ::aSelected ) == 1 .and. Eval( ::bBookMark ) == ::aSelected[ 1 ]
lRefresh := .f.
else
lRefresh := .t.
endif
::aSelected := {}
if ! Empty( ::nSaveMarq )
::nMarqueeStyle := ::nSaveMarq
::nSaveMarq := nil
endif
if lRefresh
// ::lRefreshOnlyData := .t.
::GetDC()
::Super:Refresh( .t. ) // ::Paint()
::ReleaseDC()
endif
case nOperation == 1 .or. ( Len( ::aSelected ) == 0 .and. nOperation != 4 )// Add current
uBook := Eval( ::bBookMark )
nAt := Ascan( ::aSelected, uBook )
if nAt == 0 .and. Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, uBook )
::DrawLine( .t. )
endif
case nOperation == 2 // Swap key (Ctrl+LClick)
uBook := Eval( ::bBookMark )
nAt := Ascan( ::aSelected, uBook )
if nAt > 0
::DrawLine( .f. )
::aSelected[ nAt ] := Atail( ::aSelected )
Asize( ::aSelected, Len( ::aSelected ) - 1 )
else
if Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, Eval( ::bBookMark ))
::DrawLine( .t. )
endif //daniel
endif
case nOperation == 3 // Shift & lclick
uBook := Eval( ::bBookMark )
uCurRow := ::KeyNo()
Eval( ::bBookMark, Atail( ::aSelected ) )
uOldRow := ::KeyNo()
if uOldRow != uCurRow
::aSelected := { Atail( ::aSelected ) }
if uCurRow > uOldRow
CursorWait()
do while ( uTemp := Eval( ::bBookMark ) ) != uBook .and. ! ::Eof()
If Ascan( ::aSelected, uTemp ) == 0 .and. Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, uTemp )
Endif
::Skip( 1 ) // Eval( ::bSkip, 1 )
enddo
CursorArrow()
else
CursorWait()
do while ( uTemp := Eval( ::bBookMark ) ) != uBook .and. ! ::Bof()
If Ascan( ::aSelected, uTemp ) == 0 .and. Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, uTemp )
endif
::Skip( -1 ) // Eval( ::bSkip, -1 )
enddo
CursorArrow()
endif
if Eval( ::bSelected, Self ) //daniel
Aadd( ::aSelected, uBook )
endif
Eval( ::bBookMark, uBook )
// ::lRefreshOnlyData := .t.
::GetDC()
::Paint()
::ReleaseDC()
else
Eval( ::bBookMark, uBook )
endif
case nOperation == 4 // Select all
uBook := Eval( ::bBookMark )
::aSelected := Array( ::KeyCount() )
nAt := 1
nLen := ::nLen
aTemp := ::aSelected
CursorWait()
Eval( ::bGotop )
do while nAt <= nLen //.and. !Eval( ::bEof )
if Eval( ::bSelected, Self ) //daniel
aTemp[ nAt++ ] := Eval( ::bBookMark )
endif
::Skip( 1 ) //Eval( ::bSkip, 1 )
enddo
Eval( ::bBookMark, uBook )
CursorArrow()
// ::lRefreshOnlyData := .t.
::GetDC()
::Paint()
::ReleaseDC()
end case
return nil
now Test code
#include "FiveWin.ch"
#include "xbrowse.ch"
// xbrowse imagen button get
function main()
local oDlg, oBrw
local aArray := {}
local uVal
local nI
local oGet
local nWdGet := 0
for nI = 1 to 20
aadd( aArray, { StrZero(nI,2),;
"Row:"+StrZero(nI,2)+" Col:02",;
"Row:"+StrZero(nI,2)+" Col:03",;
"Row:"+StrZero(nI,2)+" Col:04",;
"Row:"+StrZero(nI,2)+" Col:05",;
"Row:"+StrZero(nI,2)+" Col:06" } )
next
DEFINE DIALOG oDlg Title "Test xBrowse III " size 700,300
oBrw:= txbrowse():new( oDlg )
oBrw:nRowHeight := 25
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROWMS //MARQSTYLE_HIGHLCELL //
oBrw:SetArray( aArray )
oBrw:CreateFromCode()
oBrw:bSelected := {| o | if( ChangeColor( o, oBrw )[ 2 ] == CLR_HRED, .t., .f.) }
oBrw:aCols[ 2 ]:bClrStd := {|o| ChangeColor( o, oBrw ) }
oBrw:aCols[ 2 ]:bClrSelFocus := {|o| ChangeColor( o, oBrw ) }
oDlg:oClient := oBrw
ACTIVATE DIALOG oDlg center on init oDlg:Resize()
return nil
function ChangeColor( oCol, oBrw )
local aClrs := eval( oBrw:bClrStd )
DO CASE
CASE oBrw:aRow[ 1 ] == "01"
aClrs[ 2 ] := CLR_GREEN
CASE oBrw:aRow[ 1 ] == "02"
aClrs[ 2 ] := CLR_YELLOW
CASE oBrw:aRow[ 1 ] == "03"
aClrs[ 2 ] := CLR_BLUE
CASE oBrw:aRow[ 1 ] == "04"
aClrs[ 2 ] := CLR_CYAN
OTHERWISE
aClrs[ 2 ] := CLR_HRED
ENDCASE
return aClrs