Change browse cursor color dynamically

This forum is for posting of useful information
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Change browse cursor color dynamically

#1 Post by rdonnay »

This week, 2 different eXpress++ users had the same request.

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
The eXpress train is coming - and it has more cars.

Post Reply