oTree for xBrowse sample...

User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

oTree for xBrowse sample...

Post by fraxzi »

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
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Post by anserkk »

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

Check menu Tree Browse.

Regards

Anser
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Post by fraxzi »

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
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Post by fraxzi »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Frances, Detlef,

Here you have a working example:

Code: Select all

#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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

Antonio,

this is working great! :)

Many thanks for the sample,
Detlef
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Using bitmaps in the tree:

Test.prg

Code: Select all

#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

Code: Select all

open  BITMAP "c:\fwh\bitmaps\16x16\folder2.bmp"
close BITMAP "c:\fwh\bitmaps\16x16\folder.bmp"
go    BITMAP "c:\fwh\bitmaps\16x16\go.bmp" 
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

With multiple columns:

test.prg

Code: Select all

#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
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Post by anserkk »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

In order to open the browse tree with the keyboard (return key) this change in Class TXBrowse is required:

Code: Select all

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:

Code: Select all

   oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Post by anserkk »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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:

Code: Select all

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
Post Reply