ttreeview

ttreeview

Postby reinaldocrespo » Sun Sep 10, 2006 12:25 am

hi.

I'm trying to implement the use of trees for the first time. Having some trouble. I'd like to have a tree inside a dialog window that is really a tab on a folder control.

here is the code I'm using:
Code: Select all  Expand view
   REDEFINE FOLDER aoFld id 101 of oDlg       ;
         PROMPTS    "&Basic Info",    ;
            "&Abstract",    ;
            "&Discharge",    ;
            "C&onsults",    ;
            "&Notes",       ;
            "Do&cuments"   ;
         DIALOGS    "adm_TAB1",    ;
            "adm_TAB2",   ;
            "adm_TAB3",    ;
            "adm_TAB4",    ;
            "adm_docs"

   REDEFINE_Tab1( aoFld:adialogs[1], oDbf)
   REDEFINE_Tab2( aoFld:adialogs[2], oDbf)
   REDEFINE_Tab3( aoFld:adialogs[3], oDbf )
   REDEFINE_Tab4( aoFld:adialogs[4], oDbf )
   REDEFINE_documents( aofld:aDialogs[ 12 ], odbf )
.....
*-----------------------------------------------------------------------------------
static function REDEFINE_documents( odlg, odbf )
local oImageList   := TImageList():New()
local oBmp1    := TBitmap():Define( "branch",, odlg )
local oBmp2    := TBitmap():Define( "branch_Mask",, odlg )
local oTree    := TTreeView():New( 2, 0, oDlg )
local oRep1, oRep2

   oImageList:Add( oBmp1, oBmp2 )

   oTree:SetImageList( oImageList )
   oRep1 := oTree:Add( "Report1" )
   oRep1:Add( "Comp1 in Rep1" )
   oRep1:Add( "Comp2 in Rep1" )
   oRep1:Add( "Comp3 in Rep1" )
   oRep1:Add( "Comp4 in Rep1" )

   oRep2 := oTree:Add( "Report2" )

                oImageList:End()
   oBmp1:End()
   oBmp2:End()

Return Nil


When this code executes I get an error:
Code: Select all  Expand view
Application
===========
   Path and name: F:\mp\test.exe (32 bits)
   Size: 2,940,416 bytes
   Time from start: 0 hours 0 mins 16 secs
   Error occurred at: 09/09/2006, 20:08:28
   Error description: Error FiveWin/1  Non defined Id: No:    210

Stack Calls
===========
   Called from: CONTROL.PRG => TTREEVIEW:INITIATE(0)


Notice I'm not using any code with ID 210 anywhere on my code.

Can someone help?

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby Antonio Linares » Sun Sep 10, 2006 6:57 am

Reinaldo,

You have to use TTreeView():ReDefine( nId, oWnd, nClrFore, nClrBack, lDesign, cMsg ) instead of TTreeView():New( ... ).

Use SysTreeView32 as the type of the control in your dialog resource.
regards, saludos

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

Postby reinaldocrespo » Sun Sep 10, 2006 5:11 pm

Antonio;

Thank you. I no longer get the error. But, no tree is displayed. I see nothing. Another hand?

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby Antonio Linares » Sun Sep 10, 2006 6:21 pm

Reinaldo,

This code has to be executed from the ON INIT clause of the main dialog, as the tree does not has a valid hWnd before:
Code: Select all  Expand view
   oTree:SetImageList( oImageList )
   oRep1 := oTree:Add( "Report1" )
   oRep1:Add( "Comp1 in Rep1" )
   oRep1:Add( "Comp2 in Rep1" )
   oRep1:Add( "Comp3 in Rep1" )
   oRep1:Add( "Comp4 in Rep1" )

   oRep2 := oTree:Add( "Report2" )
regards, saludos

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

Postby James Bott » Sun Sep 10, 2006 6:22 pm

Reinaldo,

>Thank you. I no longer get the error. But, no tree is displayed. I see nothing. Another hand?

Perhaps because you are ending the Tree in the redefine_documents() function? I think you don't want to end the tree until the dialog is ended (this would be easier to program if you built a class instead of using functions).

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby reinaldocrespo » Sun Sep 10, 2006 6:44 pm

James;

Good to see your note.

I thought of that. Took the end() out. Same result.

Yes, making the whole thing an object would make a lot of sense. I'm just as fanatic about OOP. But I'm only adding a new tab to some very old code. Everything else is working just fine. I'm not about to re-write the whole thing now. Other things to do. Besides, Ending() the tree at dialog end() won't be a problem.

You know, I think I just thought what the problem is:

"local oBmp1 := TBitmap():Define( "branch",, odlg )"

That's the problem. It has been staring me at the eye. "Branch" is a resource. Not a file. I'll get back to you if I'm wrong on this.

Take care,


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Postby reinaldocrespo » Sun Sep 10, 2006 9:01 pm

Antonio;

Thank you. It worked!

Again, Thank you very much.


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests