Page 1 of 1
How control DCBROWSE Cursor Row Color
Posted: Tue Mar 13, 2012 5:10 am
by PedroAlex
Hello!
Question 1
We can define and control the dcbrowse cells and rows colors.
We can set a invisible row by color{0,0} but when the CURSORMODE XBPBRW_CURSOR_ROW are over this line the characters are visible
by the colors cursor row.
it is possible define the cell colors when it is selected by the cursor row??
Question 2
It is possible disable a row to be selected by the cursor row?
I mean for example I have a browse with 10 lines and I want the user can select only the lines 1,5 and 9. the other lines are visible but
the cursor row can not over that lines 'disabled'
Any help or sample!!
thanks in advance
best regards.
Re: How control DCBROWSE Cursor Row Color
Posted: Tue Mar 13, 2012 7:10 am
by Tom
Q1: Instead of selecting GRA_CLR_BACKGROUND for foreground and background colors, which should depend on a condition, just hide the cell contens using the DATA codeblock of DCBROWSECOL and the condition:
Code: Select all
DCBROWSECOL DATA {||IF(DontShow()," ",db->whatever)}
Q2: Just add some code to the ITEMMARKED block of the BROWSE:
Code: Select all
DCBROWSE oBrowse ... ITEMMARKED {||IF(NotThisLine(),oBrowse:Down(),nil)}
Whenever "NotThisLine()" fires (i.e. depending on the RecNo() or something else), hitting the line causes the cursor to move one line down. In addition, you may need to catch the situation if the browse line is the last one.
There are other and maybe more elegant solutions for this. Anyway, this should work.
Re: How control DCBROWSE Cursor Row Color
Posted: Wed Mar 14, 2012 5:20 am
by PedroAlex
Tom. Many thanks for feed Back.
On Q1 your comment give me a new light for this case.
but On Q2 maybe my explanation are not correct.
I just need a way to disable some especific rows to be hilited by the corsor row.
I just need show the line ( a dbf register or a array row ) but that row can not be hilited.
The cursor row must jump the 'disabled' lines and not be over them..
i never see a xBase sample with this solution...
but it seems to me essential
Im studying a trick
many thanks.
best Regards.
Pedro
Re: How control DCBROWSE Cursor Row Color
Posted: Wed Mar 14, 2012 5:45 am
by Wolfgang Ciriack
I think, thats definitly what Tom's example do.
If you try to click with the mouse on that item, the itemselect codeblock is fired, and it will force the cursor to go one line down (or up, whatever you do in your codeblock)
Re: How control DCBROWSE Cursor Row Color
Posted: Wed Mar 14, 2012 5:54 am
by Tom
Hi, Pedro.
The docs for DCBROWSECOL says at the WHEN clause:
WHEN <bWhen> is a code block to be evaluated before setting focus
to this column. The code block must return a logical value. If
the code block returns a .FALSE. the cell cannot be highlighted
or resized.
The pity is: This doesn't work. The WHEN clause of DCBROWSECOL seems to have almost no effect - maybe it has some if browse editing is active. However, the solution I showed to you will exactly do what you want: It's not possible to highlight the row anymore if you do something like this:
Code: Select all
DCBROWSE oBrowse ... ITEMMARKED {||IF(NoHiliteOfThisLine(),(oBrowse:Down(),oBrowse:ForceStable()),nil)}
There are a few problems with this, to be honest. If the last line is not to be highlighted, this will lead to an endless iteration. If you use keyboard navigation, you won't be able to cross that kind of line coming from below it. So, this solution needs a little more (proof if last line, store last highlighted line and so on), but in principal, it should work as you want. Just try.