FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour oTree for xBrowse sample...
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
oTree for xBrowse sample...
Posted: Sat Oct 11, 2008 08:59 AM

Hi!

Anybody with working sample using Tree for xBrowse for DBFCDX table....

Best Regards,
Frances

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
oTree for xBrowse sample...
Posted: Sat Oct 11, 2008 09:03 AM

Did you try the \FWH\Samples\TestXbr3.Prg

Check menu Tree Browse.

Regards

Anser

Posts: 811
Joined: Tue May 06, 2008 04:28 AM
oTree for xBrowse sample...
Posted: Sat Oct 11, 2008 09:07 AM

Yes I tried but I cant work it by (alias)->field....

I dont use ADO.

Regards

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
oTree for xBrowse sample...
Posted: Tue Oct 14, 2008 01:00 AM

Anyone?

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
oTree for xBrowse sample...
Posted: Tue Oct 14, 2008 09:01 AM

Frances,

You can use the source code for MakeTree() in samples\TestXbr3.prg

Just use the DBF instead of an ADO recordset. The source code is almost the same.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
oTree for xBrowse sample...
Posted: Tue Oct 14, 2008 10:27 AM
Antonio Linares wrote:Frances,

You can use the source code for MakeTree() in samples\TestXbr3.prg

Just use the DBF instead of an ADO recordset. The source code is almost the same.


Antonio,

i'm also very interested in a sample how to use this tree browse with dbf files.
Unfortunatelly it's not so easy to find a replacement for the 'union' clause of a sql query.

Could you please provide a pure dbf sample for this useful feature or give us some tips?
This woulds be great.

Thanks and regards,
Detlef
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
oTree for xBrowse sample...
Posted: Tue Oct 14, 2008 02:56 PM
Frances, Detlef,

Here you have a working example:
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()   

   local oWnd, oBrw

   USE Customer
   INDEX ON Field->State TO State
   SET ORDER TO "State"
   GO TOP
   
   DEFINE WINDOW oWnd TITLE "DbfTree"

   @ 0, 0 XBROWSE oBrw OF oWnd LINES CELL

   oBrw:SetTree( BuildTree() )

   oBrw:CreateFromCode()
   oBrw:aCols[ 1 ]:cHeader = "State"

   oWnd:oClient = oBrw
   
   ACTIVATE WINDOW oWnd
   
return nil   

static function BuildTree()

   local oTree, cState

   TREE oTree
      while ! Eof()
         if Empty( cState )
            _TreeItem( Customer->State ):Cargo := RecNo()
            TREE
            cState = Customer->State
         else
            if cState != Customer->State
               ENDTREE
               cState = Customer->State
               _TreeItem( Customer->State ):Cargo := RecNo()
               TREE
            endif   
         endif   
         if Customer->State == cState
            _TreeItem( Customer->City ):Cargo := RecNo()
         endif   
         SKIP
      enddo
      ENDTREE
   ENDTREE

   GO TOP

return oTree
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
oTree for xBrowse sample...
Posted: Tue Oct 14, 2008 02:58 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
oTree for xBrowse sample...
Posted: Tue Oct 14, 2008 03:10 PM

Antonio,

this is working great! :)

Many thanks for the sample,
Detlef

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
oTree for xBrowse sample...
Posted: Tue Oct 14, 2008 03:16 PM
Using bitmaps in the tree:

Test.prg
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()   

   local oWnd, oBrw

   USE Customer
   INDEX ON Field->State TO State
   SET ORDER TO "State"
   GO TOP
   
   DEFINE WINDOW oWnd TITLE "DbfTree"

   @ 0, 0 XBROWSE oBrw OF oWnd LINES CELL

   oBrw:SetTree( BuildTree(), { "open", "close", "go" } )

   oBrw:CreateFromCode()
   oBrw:aCols[ 1 ]:cHeader = "State"

   oWnd:oClient = oBrw
   
   ACTIVATE WINDOW oWnd
   
return nil   

static function BuildTree()

   local oTree, cState

   TREE oTree
      while ! Eof()
         if Empty( cState )
            _TreeItem( Customer->State ):Cargo := RecNo()
            TREE
            cState = Customer->State
         else
            if cState != Customer->State
               ENDTREE
               cState = Customer->State
               _TreeItem( Customer->State ):Cargo := RecNo()
               TREE
            endif   
         endif   
         if Customer->State == cState
            _TreeItem( Customer->City ):Cargo := RecNo()
         endif   
         SKIP
      enddo
      ENDTREE
   ENDTREE

   GO TOP

return oTree

Test.rc
open  BITMAP "c:\fwh\bitmaps\16x16\folder2.bmp"
close BITMAP "c:\fwh\bitmaps\16x16\folder.bmp"
go    BITMAP "c:\fwh\bitmaps\16x16\go.bmp"

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
oTree for xBrowse sample...
Posted: Tue Oct 14, 2008 04:33 PM
With multiple columns:

test.prg
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()   

   local oWnd, oBrw

   USE Customer
   INDEX ON Field->State TO State
   SET ORDER TO "State"
   GO TOP
   
   DEFINE WINDOW oWnd TITLE "DbfTree"

   @ 0, 0 XBROWSE oBrw OF oWnd LINES CELL

   oBrw:SetTree( BuildTree(), { "open", "close", "go" } )

   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 1 ] HEADER "Last"
   ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] HEADER "First"

   oBrw:CreateFromCode()
   oBrw:aCols[ 1 ]:cHeader = "State"

   oWnd:oClient = oBrw
   
   ACTIVATE WINDOW oWnd
   
return nil   

static function BuildTree()

   local oTree, cState

   TREE oTree
      while ! Eof()
         if Empty( cState )
            _TreeItem( Customer->State ):Cargo := { Space( 20 ), Space( 20 ) }
            TREE
            cState = Customer->State
         else
            if cState != Customer->State
               ENDTREE
               cState = Customer->State
               _TreeItem( Customer->State ):Cargo := { Space( 20 ), Space( 20 ) }
               TREE
            endif   
         endif   
         if Customer->State == cState
            _TreeItem( Customer->City ):Cargo := { Customer->Last, Customer->First }
         endif   
         SKIP
      enddo
      ENDTREE
   ENDTREE

   GO TOP

return oTree

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
oTree for xBrowse sample...
Posted: Wed Oct 15, 2008 05:57 AM

It's a very good sample.

What changes should I make on the above sample to display the tree if the user hit enter key also. Right now tree is displayed only when the user double click on the Data.

Regards

Anser

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
oTree for xBrowse sample...
Posted: Wed Oct 15, 2008 07:03 AM
In order to open the browse tree with the keyboard (return key) this change in Class TXBrowse is required:
METHOD KeyChar( nKey, nFlags ) CLASS TXBrowse
...
      case nKey == VK_RETURN
         oCol := ::SelectedCol()
         if oCol:nEditType > 0
            ...
         else
            If( ::oTreeItem:oTree != nil,( ::oTreeItem:Toggle(), ::Refresh() ),) // new !!!
         endif
...

In the example, to select the entire row:
   oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
oTree for xBrowse sample...
Posted: Wed Oct 15, 2008 07:50 AM

Thankyou Mr.Antonio,

Modifying the xBrowse.Prg means either I have to include the modified xBrowse.Prg along with my project

or

I should generate FiveH.Lib (Harbour) and FiveHx.Lib (xHarbour) to generate a modified lib to reflect the changes made in xBrowse.Prg. Am I right ?.

Is there a batch file available to generate FiveH.Lib and FiveHx.Lib ?.

Sorry for asking questions which is out of topic of this particular thread. I thought it might be useful for beginners like me who read this thread.

Would have been better if we had some solution without altering the xBrowse source.

Regards

Anser

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
oTree for xBrowse sample...
Posted: Wed Oct 15, 2008 08:20 AM
Anser,

You can do it both ways:

1: Modify xbrowse.prg and compile it and link it as another PRG of your application.

2: Modify xbrowse.prg and compile it and update FiveH.lib or FiveHX.lib (if you use Harbour or xHarbour)

To rebuild the library you can use this batch file:
for %%f in (*.prg) do c:\harbour\bin\harbour %%f /n /ic:\fwh\include;c:\harbour\include 
for %%f in (*.c) do c:\bcc55\bin\bcc32 -c -Ic:\bcc55\include;c:\harbour\include %%f 
for %%f in (*.obj) do c:\bcc55\bin\tlib fiveh.lib -+ %%f /0 /P32,,
regards, saludos

Antonio Linares
www.fivetechsoft.com