oTree for xBrowse sample...

oTree for xBrowse sample...

Postby fraxzi » Sat Oct 11, 2008 8: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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Postby anserkk » Sat Oct 11, 2008 9:03 am

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

Check menu Tree Browse.

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby fraxzi » Sat Oct 11, 2008 9: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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

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

Postby Antonio Linares » Tue Oct 14, 2008 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Antonio Linares » Tue Oct 14, 2008 2:56 pm

Frances, Detlef,

Here you have a working example:
Code: Select all  Expand view
#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: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Tue Oct 14, 2008 2:58 pm

Image
regards, saludos

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

Postby Detlef Hoefner » Tue Oct 14, 2008 3:10 pm

Antonio,

this is working great! :)

Many thanks for the sample,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Antonio Linares » Tue Oct 14, 2008 3:16 pm

Using bitmaps in the tree:

Test.prg
Code: Select all  Expand view
#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  Expand view
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: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Tue Oct 14, 2008 4:33 pm

With multiple columns:

test.prg
Code: Select all  Expand view
#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
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby anserkk » Wed Oct 15, 2008 5: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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Antonio Linares » Wed Oct 15, 2008 7:03 am

In order to open the browse tree with the keyboard (return key) this change in Class TXBrowse is required:
Code: Select all  Expand view
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  Expand view
   oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW

Image
regards, saludos

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

Postby anserkk » Wed Oct 15, 2008 7: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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Antonio Linares » Wed Oct 15, 2008 8: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:
Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 44 guests