Page 1 of 1

Xbrowse colors

Posted: Tue Sep 17, 2019 8:58 am
by Silvio.Falconi
Image
I colorize only some columns
the problem is when I use the MarqueeStyle I cannot use
:nMarqueeStyle := MARQSTYLE_HIGHLROW
or
:nMarqueeStyle := MARQSTYLE_HIGHLWIN7

because it not show the red colors of that columns

how I can resolve it ?

Re: Xbrowse colors

Posted: Tue Sep 17, 2019 10:42 am
by ukoenig
Silvio,

the solution You are looking for ?

Image

regards
Uwe :?:

Re: Xbrowse colors

Posted: Tue Sep 17, 2019 10:49 am
by Silvio.Falconi
yes

Re: Xbrowse colors

Posted: Tue Sep 17, 2019 11:06 am
by ukoenig
Silvio,

Code: Select all

@ 0, 0 XBROWSE oBrw OF oWnd ;
ALIAS 'CUSTOMER' AUTOCOLS ;
LINES  
//I colorize only some columns
//the problem is when I use the MarqueeStyle I cannot use 
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
//or 
//:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
//because it not show the red colors of that columns

WITH OBJECT oBrw:aCols[ 3 ] // colored column
    :bPaintText := { | oCol, hDC, cText, aRect | ;
    DRAW_RECT( oCol, hDC, cText, aRect, 255 ) } 
END

//------------------------

STATIC FUNCTION DRAW_RECT ( oCol, hDC, cText, aRect, nCellcolor )
LOCAL nTop      := aRect[ 1 ] 
LOCAL nLeft     := aRect[ 2 ] 
LOCAL nBottom   := aRect[ 3 ] 
LOCAL nRight    := aRect[ 4 ] 
LOCAL nFontHt  := GetTextHeight( oCol:oBrw:hWnd, hDC )
LOCAL nColor, Fieldvalue, hBrush1

IF nCellcolor <> NIL // Full cellcolor
     hBrush1 := CreateSolidBrush( nCellcolor ) 
     hOld1:= SelectObject( hBrush1 )
     FillRect( hDC, { nTop -1, nLeft -4, nBottom +1, nRight +2 }, hBrush1 )
     SelectObject( hOld1 )
     DeleteObject( hBrush1 )
ENDIF

//oCol:nDataStyle  0 = lefft, 1 = centered, 2 = right 
DrawTextEx( hDC, cText, { nTop, nLeft, nTop + nFontHt + 4, nRight }, 0 ) //oCol:nDataStyle )

RETURN NIL  
 
regards
Uwe :D

Re: Xbrowse colors

Posted: Tue Sep 17, 2019 11:32 am
by Silvio.Falconi
I cannot believe is not exist a command directly on xbrowse ...Nages ?

Re: Xbrowse colors

Posted: Tue Sep 17, 2019 11:49 am
by ukoenig
Silvio,

with the solution from above it is possible to color a cellpart

FillRect( hDC, { nTop -1, nRight -20, nBottom +1, nRight +4 }, hBrush1 )

Image

regards
Uwe :D

Re: Xbrowse colors

Posted: Tue Sep 17, 2019 11:57 am
by Silvio.Falconi
Uwe I have some column on red please see the picture I posted

AEval( oBrw:aCols, { |o| o:bClrStd := SetStdColor( o ) }, 2 )

static function SetStdColor( oCol )
return { || CellColor( oCol ) }

static function CellColor( oCol )

local aColor := { CLR_BLACK, CLR_WHITE }
local oBrw := oCol:oBrw
local nRow := oBrw:nArrayAt
local nCol := oCol:nCreationOrder
local cVal := oCol:Value

if ! Empty( cVal )
if nCol = 3 .or. ncol = 5 ;
.or. nCol= 7 .or. nCol= 9 .or. nCol= 11 ;
.or. nCol= 13 .or. nCol= 15 .or. nCol= 17 .or. nCol= 19 .or. nCol= 21
aColor := { CLR_WHITE, CLR_HRED }
else
aColor := { CLR_BLACK,CLR_WHITE }
endif
endif

return aColor

Re: Xbrowse colors

Posted: Tue Sep 17, 2019 12:59 pm
by ukoenig
Silvio,

very short, just a few lines

Code: Select all

@ 0, 0 XBROWSE oBrw OF oWnd ;
ALIAS 'CUSTOMER' AUTOCOLS LINES  

oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:bClrStd:= {|| { 0, 16766638 } } // Black on LightBlue

nCol := 2 // start col
FOR I := 2 TO 7
    WITH OBJECT oBrw:aCols[ nCol ]
        :bPaintText := { | oCol, hDC, cText, aRect | ;
        DRAW_RECT( oCol, hDC, cText, aRect, 255 ) } 
    END
    nCol += 2 // every 2. col
NEXT

//------------------------

STATIC FUNCTION DRAW_RECT ( oCol, hDC, cText, aRect, nCellcolor )
LOCAL nFontHt := GetTextHeight( oCol:oBrw:hWnd, hDC )

IF nCellcolor <> NIL // Full cellcolor
    hBrush1 := CreateSolidBrush( nCellcolor ) 
        hOld1   := SelectObject( hBrush1 )
    FillRect( hDC, { aRect[ 1 ] -1, aRect[ 2 ] -2, aRect[ 3 ] +1, aRect[ 4 ] + 1 }, hBrush1 ) 
    SelectObject( hOld1 )
    DeleteObject( hBrush1 )
ENDIF

DeleteObject( hBrush1 )

//oCol:nDataStyle  0 = lefft, 1 = centered, 2 = right 
DrawTextEx( hDC, cText, { aRect[ 1 ], aRect[ 2 ], aRect[ 1 ] + nFontHt + 4, aRect[ 4 ] }, 0 ) //oCol:nDataStyle )

RETURN NIL  
 
Image

regards
Uwe :D