FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TCBrowse: clicking on headers
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
TCBrowse: clicking on headers
Posted: Fri Jan 20, 2006 06:56 PM
In the following sample nothing happens when the headers are clicked. Why? How can I trap this event?

#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.

    oBrw:aActions = { { || MsgInfo( "Hello!" ) }, { || MsgInfo( "Hello!" ) } }

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

    CLOSE

    RETURN NIL


EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
TCBrowse: clicking on headers
Posted: Fri Jan 20, 2006 08:34 PM

As I expect you know, TCBrowse is a subclass of TWBrowse. aAction is eval'd in method lButtonDown in TWBrowse. In TCBrowse, the method has been completely rewritten and aAction is not used anywhere in the method. So, it looks like it will require a significant rewrite of this method to get actions working.

You might consider using TSBrowse instead. I does everything TCBrowse does and a lot more including header actions. You can get a copy at my website.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
TCBrowse: clicking on headers
Posted: Fri Jan 20, 2006 08:46 PM
James Bott wrote:As I expect you know, TCBrowse is a subclass of TWBrowse. aAction is eval'd in method lButtonDown in TWBrowse. In TCBrowse, the method has been completely rewritten and aAction is not used anywhere in the method. So, it looks like it will require a significant rewrite of this method to get actions working.

You might consider using TSBrowse instead. I does everything TCBrowse does and a lot more including header actions. You can get a copy at my website.

James


Thank you but I would prefer to not use TSBrowse. Anyway, are you saying that TCBrowse doesn't offer header clicking actions? It would be weird as when the pointer moves over headers it becomes the hand icon and there would be no reason for this.

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TCBrowse: clicking on headers
Posted: Fri Jan 20, 2006 10:43 PM
A partial fix could be (TCBrowse:LButtonDown() method):

   if ::nLen < 1
      return nil
   endif
//EMG
   if nClickRow == 0 .and. Valtype(nKeyFlags) == "N"
      if ::aActions != nil .and. ;
         ( nAtCol := ::nAtCol( nColPix ) ) <= Len( ::aActions )
            if ::aActions[ nAtCol ] != nil
               Eval( ::aActions[ nAtCol ], Self, nRowPix, nColPix )
            else
               MsgBeep()
            endif
      else
         MsgBeep()
      endif
   endif
//EMG
   if nClickRow > 0 .and. nClickRow != ::nRowPos .and. ;


and comment out

//   Super:LButtonDown( nRowPix, nColPix, nKeyFlags )

return 0


EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
TCBrowse: clicking on headers
Posted: Fri Jan 20, 2006 11:18 PM
Enrico,

I have implemented a quick fix this way:

METHOD LButtonUp( nRowPix, nColPix, nFlags ) CLASS TCBrowse

   local nClickRow, nDestCol, nAtCol

   if ::lDrag
     if ::lColDrag
        ::lDrag := .f.
     else
        return Super:LButtonUp( nRowPix, nColPix, nFlags )
     endif
   endif

   if ::lCaptured
      ::lCaptured = .f.
      ReleaseCapture()
      if ::lLineDrag
        ::lLineDrag := .f.
        ::VertLine()
      else
        ::lColDrag := .f.
        nClickRow = nTCWRow( ::hWnd, ::hDC, nRowPix,;
                      If( ::oFont != nil, ::oFont:hFont, 0 ) )

        nDestCol := ::nAtCol(nColPix)
        // we gotta be on header row within listbox and not same colm
        if nClickRow == 0 .and. nColPix > ::nLeft .and. ;
           nColPix < ::nRight - 16 .and. ::nDragCol != nDestCol
             ::Exchange( ::nDragCol, nDestCol)
        else 
          if ::aActions != nil .and. ;
             ( nAtCol := ::nAtCol( nColPix ) ) <= Len( ::aActions )
             if ::aActions[ nAtCol ] != nil
                Eval( ::aActions[ nAtCol ], Self, nRowPix, nColPix )
             endif
          endif
        endif
      endif
   endif

   Super:LButtonUp( nRowPix, nColPix, nFlags )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
TCBrowse: clicking on headers
Posted: Fri Jan 20, 2006 11:24 PM

Thank you!

EMG

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
TCBrowse: clicking on headers
Posted: Wed Feb 15, 2006 05:44 PM

Headers clicking still doesn't work on the February build.

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
TCBrowse: clicking on headers
Posted: Wed Feb 15, 2006 05:56 PM

Enrico,

Please try fwh\samples\enrico.prg :)

Its working fine :)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
TCBrowse: clicking on headers
Posted: Wed Feb 15, 2006 07:04 PM
Antonio Linares wrote:Enrico,

Please try fwh\samples\enrico.prg :-)

Its working fine :-)


Ok, but try this enrico2.prg:

#include "Fivewin.ch" 
#include "Tcbrowse.ch" 


FUNCTION MAIN() 

    LOCAL oDlg, oBrw, oCol 

    USE Customer ALIAS 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. 
    oBrw:lMChange = .F.

    oBrw:aActions = { { || MsgInfo( "One!" ) }, { || MsgInfo( "Two!" ) } } 

    ACTIVATE DIALOG oDlg; 
             ON INIT oDlg:SetControl( oBrw ); 
             CENTER ;
             VALID MsgYesNo( "Want to exit ?" )

    CLOSE 

    RETURN NIL


:-)

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
TCBrowse: clicking on headers
Posted: Wed Feb 15, 2006 08:57 PM

Enrico,

This line is causing the problem:

oBrw:lMChange = .f.

but here you have a modified Class TCBrowse that works ok with your sample: http://hyperupload.com/download/a4efe52 ... e.prg.html :)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
TCBrowse: clicking on headers
Posted: Wed Feb 15, 2006 09:29 PM

Thank you.

EMG

Continue the discussion