Page 1 of 2

DCBROWSECOL COLOR lost on highlighted line with Xbase++ v2

Posted: Thu Aug 10, 2017 4:10 am
by reganc
We have a customer who extensively uses a dialog containing a browse displaying Invoice and Credit Notes.
The DCBROWSECOL...COLOR clause is used to set the foreground color of the items.
Invoices are set to GRA_CLR_BLACK.
Credit Notes are set to GRA_CLR_RED.
This coloring also shows correctly on the currently highlighted row.

And this worked fine when they were using an application built with Xbase++ 1.9.

They have now switched to an application built with Xbase++ 2.0 and the coloring is Ok on the non-highlighted lines but the highlighted line is only ever shown with a black foreground text color.

Can you tell me if this is this an Xbase++ issue or an Express++ one?

Re: DCBROWSECOL COLOR lost on highlighted line with Xbase++

Posted: Thu Aug 10, 2017 4:43 am
by rdonnay
Have you a small snippet of code that I can compile and run?

Re: DCBROWSECOL COLOR lost on highlighted line with Xbase++

Posted: Thu Aug 10, 2017 9:40 am
by reganc
rdonnay wrote:Have you a small snippet of code that I can compile and run?
I'll get one together on Monday as I'm off until then (going to a Hot Air Balloon Festival for the weekend).

Thanks.

Re: DCBROWSECOL COLOR lost on highlighted line with Xbase++

Posted: Thu Aug 10, 2017 10:23 am
by Wolfgang Ciriack
Change all color arrays from a 2 value array to a 4 color array.

Re: DCBROWSECOL COLOR lost on highlighted line with Xbase++

Posted: Mon Aug 14, 2017 7:15 am
by reganc
Wolfgang Ciriack wrote:Change all color arrays from a 2 value array to a 4 color array.
Thanks, Wolfgang. That worked perfectly.

Roger, does this mean that the code that handles a color array returned from a codeblack has a bug in it?

Re: DCBROWSECOL COLOR lost on highlighted line with Xbase++

Posted: Mon Aug 14, 2017 8:13 am
by rdonnay
Roger, does this mean that the code that handles a color array returned from a codeblack has a bug in it?
I'm not sure what you did.

Show me the before and after code.

Re: DCBROWSECOL COLOR lost on highlighted line with Xbase++

Posted: Mon Aug 14, 2017 11:36 am
by reganc
rdonnay wrote:
Roger, does this mean that the code that handles a color array returned from a codeblack has a bug in it?
I'm not sure what you did.

Show me the before and after code.
OK. Old code:

Code: Select all

STATIC FUNCTION LP_OrdColor(aLedger,aItem)

   LOCAL aColor, cAUTH

   aColor := {NIL,NIL}
   if ValType(aItem) = "A"
      if aItem[LP_ITEM_EL_TYPE] == "C" // credit note
         aColor:={GRA_CLR_RED,NIL}
         if aLedger[LP_EL_LEDGER] == "P" .and. !empty(aItem[LP_ITEM_EL_AUTH])
            if Get_Auth_From_Word(aItem[LP_ITEM_EL_AUTH])$"QN"
               aColor:={GraMakeRGBColor( { 225 , 140 , 140 } ),NIL}
            endif
         endif
      else
         if aLedger[LP_EL_LEDGER] == "P" .and. !empty(aItem[LP_ITEM_EL_AUTH])
            cAUTH:=Get_Auth_From_Word(aItem[LP_ITEM_EL_AUTH])
            if cAUTH == "Q" // query
               aColor:={GRA_CLR_DARKPINK,NIL}
            elseif cAUTH == "N" // held / not authorised
               aColor:={GRA_CLR_DARKGREEN,NIL}
            endif
         endif
      endif
   endif
RETURN aColor
New Code:

Code: Select all

STATIC FUNCTION LP_OrdColor(aLedger,aItem)

   LOCAL aColor, cAUTH

   aColor := {NIL,NIL,NIL,NIL}
   if ValType(aItem) = "A"
      if aItem[LP_ITEM_EL_TYPE] == "C" // credit note
         aColor:={GRA_CLR_RED,NIL,GRA_CLR_RED,NIL}
         if aLedger[LP_EL_LEDGER] == "P" .and. !empty(aItem[LP_ITEM_EL_AUTH])
            if Get_Auth_From_Word(aItem[LP_ITEM_EL_AUTH])$"QN"
               aColor:={GraMakeRGBColor( { 225 , 140 , 140 } ),NIL,GraMakeRGBColor( { 225 , 140 , 140 } ),NIL}
            endif
         endif
      else
         if aLedger[LP_EL_LEDGER] == "P" .and. !empty(aItem[LP_ITEM_EL_AUTH])
            cAUTH:=Get_Auth_From_Word(aItem[LP_ITEM_EL_AUTH])
            if cAUTH == "Q" // query
               aColor:={GRA_CLR_DARKPINK,NIL,GRA_CLR_DARKPINK,NIL}
            elseif cAUTH == "N" // held / not authorised
               aColor:={GRA_CLR_DARKGREEN,NIL,GRA_CLR_DARKGREEN,NIL}
            endif
         endif
      endif
   endif
RETURN aColor
I didn't really have a clue what values to put into the 4 element array so I had to assume the 1st two elements were a FG and BG pair and the last two were too.

Re: DCBROWSECOL COLOR lost on highlighted line with Xbase++

Posted: Tue Aug 15, 2017 5:07 am
by Wolfgang Ciriack
I didn't really have a clue what values to put into the 4 element array so I had to assume the 1st two elements were a FG and BG pair and the last two were too.
I use this for changing some colors when the cursor is on this line, for example
{GRA_CLR_WHITE,GRA_CLR_DARKGREEN,GRA_CLR_DARKGREEN,nil}

Re: DCBROWSECOL COLOR lost on highlighted line with Xbase++

Posted: Wed Aug 16, 2017 1:56 am
by reganc
Wolfgang Ciriack wrote:
I didn't really have a clue what values to put into the 4 element array so I had to assume the 1st two elements were a FG and BG pair and the last two were too.
I use this for changing some colors when the cursor is on this line, for example
{GRA_CLR_WHITE,GRA_CLR_DARKGREEN,GRA_CLR_DARKGREEN,nil}
Out of interest, how did you find out about the 4 elements needed? I cannot find any mention of it in the documentation.

Re: DCBROWSECOL COLOR lost on highlighted line with Xbase++

Posted: Wed Aug 16, 2017 7:36 am
by Cliff Wiernik
I found out about the NIL process from Roger. That appears to cause the normal color to occur.