They needed to be able to dynamically change the row cursor color of a browse when the browse row is selected either by navigation keys or the mouse. In this example the color is White on Red when the file size in the data array of the selected row is greater than 10,000, otherwise it is White on Blue.
Code: Select all
#INCLUDE "dcdialog.CH"
FUNCTION Main()
LOCAL GetList[0], aDir := Directory(), oBrowse, i
@ 0,0 DCBROWSE oBrowse DATA aDir SIZE 100, 20 ;
FONT '10.Lucida Console' ;
CURSORMODE XBPBRW_CURSOR_ROW ;
ITEMMARKED {|a,b,o|SetHiliteColor(o,aDir), ;
DC_ClearEvents()}
FOR i := 1 TO 10
DCBROWSECOL ELEMENT i HEADER Alltrim(Str(i)) WIDTH 10 PARENT oBrowse
NEXT
DCREAD GUI FIT TITLE 'Cursor Color Test'
RETURN nil
* ---------
PROC appsys ; RETURN
* ---------
STATIC FUNCTION SetHiliteColor( oBrowse, aDir )
LOCAL i, oColumn, aData := aDir[oBrowse:arrayElement]
FOR i := 1 TO oBrowse:colCount
oColumn := oBrowse:getColumn(i)
IF aData[2] > 10000 // file size
oColumn:dataArea:setcellHiliteColor( oBrowse:rowPos,GRA_CLR_WHITE,GRA_CLR_RED, .t. )
ELSE
oColumn:dataArea:setcellHiliteColor( oBrowse:rowPos,GRA_CLR_WHITE,GRA_CLR_BLUE, .t. )
ENDIF
NEXT
RETURN nil