Page 1 of 1

Two bugs on TCBrowse

PostPosted: Fri Jan 20, 2006 4:11 pm
by Enrico Maria Giordano
The following sample shows two little bugs:

1. How to get rid of the ugly black background on the not focused cells?

2. Why the dialog can't be closed using ESC?

Code: Select all  Expand view
#include "Fivewin.ch"
#include "Tcbrowse.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw, oCol

    USE TEST

    DEFINE DIALOG oDlg SIZE 300, 300

    @ 0, 0 BROWSE oBrw

    ADD COLUMN TO oBrw;
               DATA TEST -> last;
               HEADER "LAST";
               COLOR CLR_RED, CLR_GREEN

    ADD COLUMN TO oBrw;
               DATA TEST -> first;
               HEADER "FIRST";
               COLOR CLR_RED, CLR_GREEN

    oBrw:lCellStyle = .T.

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:SetControl( oBrw );
             CENTER

    CLOSE

    RETURN NIL


EMG

Re: Two bugs on TCBrowse

PostPosted: Fri Jan 20, 2006 10:02 pm
by Enrico Maria Giordano
This is the fix for point 1 (part of TCBrowse:DrawSelect() method):

Code: Select all  Expand view
        else
          if ! ::lCellStyle .or. ::nColAct == nJ
             nClrFore := nClrForeFocus
          else
             if (bClrFore := oColumn:bClrFore) == nil // backgnd nClrBackFocus
                nClrFore = ::nClrText
             else
                nClrFore = bClrFore
             endif

             if ValType( nClrFore ) == "B" //EMG
                nClrFore = Eval( nClrFore, nRowPos, nJ ) //EMG
             endif //EMG
          endif
          if ! ::lCellStyle .or. ::nColAct == nJ
             nClrBack := nClrBackFocus
          else
             if (bClrBack := oColumn:bClrBack) == nil // backgnd nClrBackFocus
                nClrBack = ::nClrPane
             else
                nClrBack = bClrBack
             endif

             if ValType( nClrBack ) == "B" //EMG
                nClrBack = Eval( nClrBack, nRowPos, nJ ) //EMG
             endif //EMG
          endif
        endif


EMG

PostPosted: Fri Jan 20, 2006 10:28 pm
by Antonio Linares
Enrico,

Thanks for the fix! :)

PostPosted: Fri Jan 20, 2006 10:42 pm
by Antonio Linares
Enrico,

For the ESC bug, make these changes in source\classes\control:

METHOD KeyDown( nKey, nFlags ) CLASS TControl

if nKey == VK_ESCAPE
::oWnd:KeyChar( nKey, nFlags )
return 0
endif

...

and remove that portion of code from KeyChar(...) CLASS TControl.

PostPosted: Fri Jan 20, 2006 10:44 pm
by Enrico Maria Giordano
Thank you!

EMG