FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Tcbrowse 2 colour one for each line
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Tcbrowse 2 colour one for each line
Posted: Thu Nov 15, 2007 03:43 PM

Hi,

Is there any way to have a 2 colours one for each line in tcbrowse with / wihtou lcellstyle

Antonio

Regards

Antonio H Ferreira
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Tcbrowse 2 colour one for each line
Posted: Thu Nov 15, 2007 10:52 PM

Antonio,

Do you mean using FWH own Class TCBrowse ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Tcbrowse 2 colour one for each line
Posted: Thu Nov 15, 2007 11:11 PM

Yes.

Antonio

Regards

Antonio H Ferreira
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Tcbrowse 2 colour one for each line
Posted: Thu Nov 15, 2007 11:23 PM

AHF,

The below info is from my notes file. Note that you have indexes, filters, and deleted records to handle, so the solution has to consider these.

James


8/24/2007 Update: Antonio posted this one.

oBrw:nClrPane := { || If( OrdKeyNo() % 2 == 0, RGB( 230, 230, 230), RGB( 190, 215, 190 ) ) }

This is a much better one, but only for objects. Unfortunately dbskip() only returns nil so you can't do this without a database object. [Update: There is an undocumented function _dbskipper() that does return the number of records skipped, so perhaps this could be done without a database object.]

lClrFlag:=.f.

oLbx:bSkip:={| nRecs | (nRecs:= ::oInvmast:skipper( nRecs ), lClrFlag:=if(nRecs/2 = int(nRecs/2), lClrFlag,!lClrFlag), nRecs) }

oLbx:nClrPane := { || if(lClrFlag, rgb(255,255,235), rgb(192,208,179)) }

The above works with or without indexes, filters, and deleted records.

// end

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Tcbrowse 2 colour one for each line
Posted: Thu Nov 15, 2007 11:50 PM

James,

Thanks.

Antonio

Regards

Antonio H Ferreira
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Tcbrowse 2 colour one for each line
Posted: Fri Nov 16, 2007 08:35 AM
AHF,

here is another working solution

...
::oBrw:bBkColor := {|nRow,nCol,nStyle| TcBrwCol (nRow,nStyle,::oBrw,  aColorK) }
...

FUNCTION TcBrwCol ( nRow, nStyle, oBrw, aColor )

LOCAL nColor

DEFAULT aColor := {RGB( 102, 205, 170 ),RGB( 32, 178, 170 )}

//IF nStyle = 0
   IF IsEven( nRow )
      nColor := aColor[1]
   ELSE
      nColor := aColor[2]
   ENDIF
//ENDIF

RETURN ( nColor )


FUNCTION IsEven( nVal )
RETURN IIF( nVal = Round( nVal/2, 0 )*2, .T., .F. )
kind regards

Stefan
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Tcbrowse 2 colour one for each line
Posted: Fri Nov 16, 2007 09:49 AM

Problem solved. Thanks for your help.

Antonio

Regards

Antonio H Ferreira
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Tcbrowse 2 colour one for each line
Posted: Wed Jan 09, 2008 02:56 PM

Hello,

I return to same problem because using OrdKeyNo in a network the application is crawling. Without it it works great!. However the users are claiming for a 2 colors lines.
How can I solve it ?

Any ideas ?

Antonio

Regards

Antonio H Ferreira
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Tcbrowse 2 colour one for each line
Posted: Wed Jan 09, 2008 04:28 PM

AHF,

There are two solutions above that don't use OrdKeyNo(), have you tried them?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Tcbrowse 2 colour one for each line
Posted: Wed Jan 09, 2008 04:35 PM

James,

Yes.
The problem with those solutions is when you begin to skip over the last visible line of the browse (line by line) you always get the smae rownr and it stops working.
It only works when you repaint all the browse. (pg up or down)

Antonio

Regards

Antonio H Ferreira
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Tcbrowse 2 colour one for each line
Posted: Wed Jan 09, 2008 04:37 PM

AHF,

>The problem with those solutions is when you begin to skip over the last visible line of the browse (line by line) you always get the smae rownr and it stops working.
It only works when you repaint all the browse. (pg up or down)

I have never had that problem. Can we see the code you are using?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Tcbrowse 2 colour one for each line
Posted: Wed Jan 09, 2008 05:03 PM
AHF,

Below is a working example. Use it with the fw\samples\customer.dbf file.

Regards,
James

// Purpose : Sample TCBrowse with alternating color rows
// Author  : James Bott
// Date    : 1/9/2008

#include "fivewin.ch"
#include "TCBrowse.ch"    // <-- Important

function main()
   local oWnd, oCustomer, oBrw, lClrFlag

   use customer
   database oCustomer

   define window oWnd title "TCBrowse Test"

   @ 0,0 browse oBrw of oWnd update

   oBrw:setoDBF( oCustomer )
   oBrw:cAlias := oCustomer:cAlias // required

   add column to browse oBrw field first

   add column to browse oBrw field last

   lClrFlag:=.f.

   oBrw:bSkip:={| nRecs | (nRecs:= oCustomer:skipper( nRecs ), lClrFlag:=if(nRecs/2 = int(nRecs/2), lClrFlag,!lClrFlag), nRecs) }

   oBrw:nClrPane := { || if(lClrFlag, rgb(255,255,235), rgb(192,208,179)) }

   oWnd:oClient:=oBrw

   activate window oWnd

return nil
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Tcbrowse 2 colour one for each line
Posted: Wed Jan 09, 2008 05:44 PM

James,

I don't work with database objects. I have my own skip blocks.

Antonio

Regards

Antonio H Ferreira
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Tcbrowse 2 colour one for each line
Posted: Wed Jan 09, 2008 05:47 PM

AHF,

>I don't work with database objects. I have my own skip blocks.

Database objects are not required. Show me your skipblock.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Tcbrowse 2 colour one for each line
Posted: Wed Jan 09, 2008 05:48 PM

Antonio,

Stefan proposed you, in this thread, a solution that does not use the DBF at all.

Its based on the painted row number. Please review it, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com