FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Necesito ayuda con Tree
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Necesito ayuda con Tree
Posted: Wed Jan 19, 2022 10:25 PM
Hola a todos.

Estoy ahora tratando de hacer una funci贸n en la que se inscriban acuerdo de empresas en libros de inscripciones. Muchos de vosotros ya conocer茅is lo que es un tomo de libro inscripciones del Registro de la Propiedad, por ejemplo, pero en este caso se trata de empresas en la que se inscriben acuerdos (no es el Registro Mercantil).

Pues estoy trantado de hacer con un splitter y un otree ver la forma de c贸mo hacerlo. Ver茅is, cada tomo contiene 200 folios (tama帽o un poco menor que un A3), por anverso y reverso, y de lo que se trata es de digitalizar lo que hay en papel y continuar con el pdf generado de los libro sy a partir de ah铆 hacer las inscripciones con el acrobat profesional. El otree m谩s o menos lo tengo claro, pero me gustar铆a que se ver铆a en la ventana de la derecha el pdf.

Aqu铆 ten茅is una composici贸n de la de lo que ser铆a la idea:


El c贸digo con el que he empezado el tema es este:

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "Splitter.ch"

//----------------------------------------------------------------------------//

function Main()

聽 聽local oWnd, oBar, oTree, oItem1, oItem2, oBmp1, oBmp2, oImageList, oSplit

聽 聽DEFINE WINDOW oWnd FROM 3, 6 TO 20, 70 ;
聽 聽 聽 TITLE "Libro de registro de empresas" 

聽 聽DEFINE BUTTONBAR oBar OF oWnd _3D

聽 聽DEFINE BUTTON RESOURCE "open" OF oBar ACTION oTree:aItems[ 1 ]:Expand() ;
聽 聽 聽 TOOLTIP "Expand" NOBORDER

聽 聽DEFINE BUTTON RESOURCE "close" OF oBar ACTION oTree:aItems[ 1 ]:Collapse() ;
聽 聽 聽 TOOLTIP "Colapse" NOBORDER

聽 聽DEFINE BUTTON RESOURCE "open" OF oBar ACTION oTree:ExpandAll() ;
聽 聽 聽 TOOLTIP "Expand all items" NOBORDER

聽 聽DEFINE BUTTON RESOURCE "close" OF oBar ACTION oTree:ColapseAll() ;
聽 聽 聽 TOOLTIP "Colapse all items" NOBORDER

聽 聽DEFINE BUTTON RESOURCE "close" OF oBar ACTION oTree:GetSelected():SetText( Time() ) ;
聽 聽 聽 TOOLTIP "Change Text" NOBORDER

聽 聽oImageList = TImageList():New()

聽 聽oBmp1 = TBitmap():Define( "folder",, oWnd )
聽 聽oBmp2 = TBitmap():Define( "fldMask",, oWnd )

聽 聽oImageList:Add( oBmp1, oBmp2 )

聽 聽oTree = TTreeView():New( 2, 0, oWnd )

聽 聽oTree:bChanged = { || oWnd:SetText( If( oTree:GetSelected():GetParent() != nil,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oTree:GetSelected():GetParent():cPrompt + " + ", "" ) + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oTree:GetSelText() ) }
聽 聽oTree:SetImageList( oImageList )

聽 聽oItem1 = oTree:Add( "Tomo 1" )

聽 聽oItem2 = oItem1:Add( "Folio 1" )
聽 聽 聽 oItem2:Add( "Anverso" )
聽 聽 聽 oItem2:Add( "Reverso" )

聽 聽 聽oItem2 = oTree:Add( "Tomo 2" )

聽 聽 聽 oItem2 = oItem2:Add( "Folio 2" )
聽 聽 聽 oItem2:Add( "Anverso" )
聽 聽 聽 oItem2:Add( "Reverso" )

聽 聽



聽 聽@ 29, 200 SPLITTER oSplit ;
聽 聽 聽 VERTICAL _3DLOOK ;
聽 聽 聽 PREVIOUS CONTROLS oTree ;
聽 聽 聽 SIZE 4, 200 PIXEL ;
聽 聽 聽 OF oWnd

聽 聽ACTIVATE WINDOW oWnd ;
聽 聽 聽 ON RESIZE oSplit:AdjClient()

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

return nil

//----------------------------------------------------------------------------//

procedure AppSys 聽// Xbase++ requirement

return

//----------------------------------------------------------------------------//
FWH 20.12 BCC7
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Necesito ayuda con Tree
Posted: Wed Jan 19, 2022 11:38 PM
Bueno, yo no creo que en tu caso sea necesario un tree ( usaria un browse con una lista de los "Folios" nada m谩s ), pero a ver si te sirve de algo
Tendr谩s que aplicar en el bChange del oTree o en el click
Pero, para que veas lo que quiero decir, creo que te puede servir.

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "Splitter.ch"

Static oPdfActX
Static oPdfPdfX

// Pon un fichero que exista
Static cFilePdf 聽:= "testrtf.pdf"

//----------------------------------------------------------------------------//

function Main()

聽 聽local oWnd, oBar, oTree, oItem1, oItem2, oBmp1, oBmp2, oImageList, oSplit

聽 聽DEFINE WINDOW oWnd FROM 3, 6 TO 700, 1200 PIXEL ;
聽 聽 聽 TITLE "Libro de registro de empresas"

聽 聽DEFINE BUTTONBAR oBar OF oWnd _3D

聽 聽DEFINE BUTTON RESOURCE "open" OF oBar ACTION oTree:aItems[ 1 ]:Expand() ;
聽 聽 聽 TOOLTIP "Expand" NOBORDER

聽 聽DEFINE BUTTON RESOURCE "close" OF oBar ACTION oTree:aItems[ 1 ]:Collapse() ;
聽 聽 聽 TOOLTIP "Colapse" NOBORDER

聽 聽DEFINE BUTTON RESOURCE "open" OF oBar ACTION oTree:ExpandAll() ;
聽 聽 聽 TOOLTIP "Expand all items" NOBORDER

聽 聽DEFINE BUTTON RESOURCE "close" OF oBar ACTION oTree:ColapseAll() ;
聽 聽 聽 TOOLTIP "Colapse all items" NOBORDER

聽 聽DEFINE BUTTON RESOURCE "close" OF oBar ACTION oTree:GetSelected():SetText( Time() ) ;
聽 聽 聽 TOOLTIP "Change Text" NOBORDER


聽 聽oImageList = TImageList():New()

聽 聽oBmp1 = TBitmap():Define( "folder",, oWnd )
聽 聽oBmp2 = TBitmap():Define( "fldMask",, oWnd )

聽 聽oImageList:Add( oBmp1, oBmp2 )

聽 聽oTree = TTreeView():New( 2, 0, oWnd )

聽 聽oTree:bChanged = { || oWnd:SetText( If( oTree:GetSelected():GetParent() != nil,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oTree:GetSelected():GetParent():cPrompt + " + ", "" ) + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oTree:GetSelText() ) }
聽 聽oTree:SetImageList( oImageList )

聽 聽oItem1 = oTree:Add( "Tomo 1" )

聽 聽oItem2 = oItem1:Add( "Folio 1" )
聽 聽 聽 oItem2:Add( "Anverso" )
聽 聽 聽 oItem2:Add( "Reverso" )

聽 聽 聽oItem2 = oTree:Add( "Tomo 2" )

聽 聽 聽 oItem2 = oItem2:Add( "Folio 2" )
聽 聽 聽 oItem2:Add( "Anverso" )
聽 聽 聽 oItem2:Add( "Reverso" )

聽 聽@ 29, 200 SPLITTER oSplit ;
聽 聽 聽 VERTICAL _3DLOOK ;
聽 聽 聽 PREVIOUS CONTROLS oTree ;
聽 聽 聽 HINDS CONTROLS oPdfActX ;
聽 聽 聽 SIZE 4, 200 PIXEL ;
聽 聽 聽 OF oWnd

聽 聽ACTIVATE WINDOW oWnd ;
聽 聽 聽 ON INIT ( ShowPdf1( oWnd, cFilePdf, oBar:nBottom + 2, oSplit:nRight + 2, oWnd:nWidth - oSplit:nRight - 10, oWnd:nBottom - oBar:nBottom - 20 ) ) ;
聽 聽 聽 ON RESIZE oSplit:AdjClient()

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

return nil

//----------------------------------------------------------------------------//

procedure AppSys 聽// Xbase++ requirement

return

//----------------------------------------------------------------------------//
聽
Static Function ShowPDF1( oWnd, cFile, nT, nL, nW, nH )

聽 聽hb_default( @nT, 0 )
聽 聽hb_default( @nL, 0 )
聽 聽hb_default( @nW, oWnd:nWidth/2 - 4 )
聽 聽hb_default( @nH, oWnd:nHeight/2 - 19 )
聽 聽if Valtype( oPdfActX ) != "O"
聽 聽 聽 oPdfActX 聽:= TActiveX():New( oWnd, "AcroPDF.PDF.1", nT, nL, nW, nH )
聽 聽 聽 if !Empty( oPdfActX ) .and. Valtype( oPdfActX ) = "O"
聽 聽 聽 聽 聽//oPdfActX:nDlgCode = DLGC_WANTALLKEYS
聽 聽 聽 聽 聽//oPdfActX:bLClicked := { || MsgInfo( "Hello1" ) }
聽 聽 聽 聽 聽//oPdfActX:bGotFocus := { || oWnd:SetFocus() }
聽 聽 聽 聽 聽//oPdfActX:bOnEvent := { | event, aParams, pParams | EventInfo( event, aParams, pParams ) }
聽 聽 聽 聽 聽VerDocPdf( cFile )
聽 聽 聽 endif
聽 聽else
聽 聽 聽 VerDocPdf( cFile )
聽 聽endif
Return oPdfActX

//----------------------------------------------------------------------------//
// <!-- m --><a class="postlink" href="https://metacpan.org/pod/Wx::ActiveX::Acrobat">https://metacpan.org/pod/Wx::ActiveX::Acrobat</a><!-- m -->#SetPageMode
//----------------------------------------------------------------------------//

Static Function VerDocPdf( cFile )
聽 聽local cOld
聽 聽local oE
聽 聽hb_default( @cFile, "" )
聽 聽cFile 聽 聽:= AllTrim( cFile )
聽 聽if Valtype( oPdfActX ) = "O"
聽 聽 聽 TRY
聽 聽 聽 聽 聽SysWait( 0.5 )
聽 聽 聽 聽 聽cOld 聽 := oPdfActX:Src()
聽 聽 聽 聽 聽if ( Valtype( cOld ) = "C" .and. cFile != "-" .and. ;
聽 聽 聽 聽 聽 聽 聽 Upper( AllTrim( cFile ) ) != Upper( AllTrim( cOld ) ) ) .or. Empty( cOld )
聽 聽 聽 聽 聽 聽 oPdfActX:Do( "GetVersions" )
聽 聽 聽 聽 聽 聽 oPdfActX:Do( "setShowToolbar", 0 )
聽 聽 聽 聽 聽 聽 oPdfActX:Do( "setShowScrollbars", 0 )
聽 聽 聽 聽 聽 聽 //oPdfActX:Do( "setView", "fitB" ) //"fitH" )
聽 聽 聽 聽 聽 聽 oPdfActX:Do( "setPageMode", "none" ) 聽//, "bookmarks" ) 聽//

// 聽 聽 聽 聽 聽 聽oPdfActX:Do( "setLayoutMode", "SinglePage" )
聽 聽 聽 聽 聽 聽 oPdfActX:Do( "setLayoutMode", "TwoColumnLeft" )

聽 聽 聽 聽 聽 聽 oPdfActX:Do( "LoadFile", cFile )
聽 聽 聽 聽 聽 聽 oPdfActX:Do( "SetCurrentPage", 1 )
聽 聽 聽 聽 聽 聽 //oPdfActX:Do( "postMessage", 0 )

聽 聽 聽 聽 聽 聽 // Ver "setView"
聽 聽 聽 聽 聽 聽 //oPdfActX:SetZoom( 51.0 ) 聽 聽 聽 聽// 1 .. 100 %

聽 聽 聽 聽 聽 聽 oPdfActX:Show()
聽 聽 聽 聽 聽 聽 //oPdfActX:Refresh()
聽 聽 聽 聽 聽 聽 //SysRefresh()
聽 聽 聽 聽 聽endif
聽 聽 聽 CATCH oE
聽 聽 聽 聽 聽if cFile != "-" .and. !Empty( cFile )
聽 聽 聽 聽 聽 聽 MsgInfo( cFile, "No se ha podido cargar el Documento" )
聽 聽 聽 聽 聽endif
聽 聽 聽 END
聽 聽endif

Return oPdfActX

//----------------------------------------------------------------------------//

Static Function EventInfo( event, aParams, pParams )

聽 聽local n
聽 聽local cMsg := "Event: " + cValToChar( event ) + CRLF
聽 聽cMsg += "Params: " + CRLF
聽 聽for n := 1 to Len( aParams )
聽 聽 聽 cMsg += cValToChar( aParams[ n ] ) + CRLF
聽 聽next
Return cMsg

//----------------------------------------------------------------------------//
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 06:42 AM

Ram贸n,

Revisa FWH\samples\pim.prg

buildh.bat pim

Ya que tiene mucha de la funcionalidad que comentas, la diferencia es que en el lado derecho se usa un control RichEdit,
pero desde ese RichEdit puedes mostrar letras de distintos tama帽os y colores, e im谩genes :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 07:10 AM

Gracias, Crist贸bal, Antonio. Probar茅 vuestras sugerencias.

Saludos

FWH 20.12 BCC7
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 07:22 AM

Antonio, perdona que te moleste. He intentado compilar pimp.prg como me has sugerido pero me da este error:

Compiling...
Harbour 3.2.0dev (r2008190002)
Copyright (c) 1999-2020, https://harbour.github.io/
Compiling 'pim.prg' and generating preprocessed output to 'pim.ppo'...
pim.prg(6) Error F0029 Can't open #include file 'c:\harbour\contrib\xhb\hbxml.ch'
* Compile errors *

C:\fwh\samples>

Efectivamente, dentro de Harbour no tengo la carpeta de contrib. 驴D贸nde se puede conseguir para compilar pim.prg y probarlo?

Un saludo

FWH 20.12 BCC7
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 07:37 AM
Buenos d铆as, Crist贸bal

Al compilar tu ejemplo, me da este error:



Saludos
FWH 20.12 BCC7
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 08:44 AM
Ram贸n J. wrote:Antonio, perdona que te moleste. He intentado compilar pimp.prg como me has sugerido pero me da este error:

Compiling...
Harbour 3.2.0dev (r2008190002)
Copyright (c) 1999-2020, https://harbour.github.io/
Compiling 'pim.prg' and generating preprocessed output to 'pim.ppo'...
pim.prg(6) Error F0029 Can't open #include file 'c:\harbour\contrib\xhb\hbxml.ch'
* Compile errors *

C:\fwh\samples>

Efectivamente, dentro de Harbour no tengo la carpeta de contrib. 驴D贸nde se puede conseguir para compilar pim.prg y probarlo?

Un saludo


https://github.com/harbour/core/tree/master/contrib
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 09:29 AM

Gracias, Antonio

FWH 20.12 BCC7
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 10:52 AM
Pues es muy raro
Si construyes el ejemplo tal cual lo he puesto me funciona correctamente
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 11:47 AM
cnavarro wrote:Pues es muy raro
Si construyes el ejemplo tal cual lo he puesto me funciona correctamente


Desde cual version esto ejiste? Esto no funciona bien.

Code (fw): Select all Collapse
   ACTIVATE WINDOW oWnd ;
      ON INIT ( ShowPdf1( oWnd, cFilePdf, oBar:nBottom + 2, oSplit:nRight + 2, oWnd:nWidth - oSplit:nRight - 10, oWnd:nBottom - oBar:nBottom - 20 ) ) ;
      ON RESIZE oSplit:AdjClient()


Saludos
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 01:58 PM

Crist贸bal, lo he copiado tal cual lo has puesto y lo he compilado. No he tocado nada. Tengo la versi贸n FWH 20-12

Saludos

FWH 20.12 BCC7
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 04:45 PM

Ram贸n, prueba comentando la clausula ON RESIZE y me dices

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 07:10 PM
Crist贸bal, he probado quitando la cla煤sula ON RESIZE y ya no da error, pero no muestra el pdf. Me he asegurado de que el pdf "testrtf.pdf" est谩 en el mismo directorio que el exe que genera.

Mira c贸mo sale:

FWH 20.12 BCC7
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 07:36 PM
Master Navarro, compilando PIM.PRG me genera este error, que esta errado?


Code (fw): Select all Collapse
PIM.prg(214) Error E0030  Syntax error: "syntax error at '@'"

   @ 0, 205 RICHEDIT5 oMemo VAR cItemText OF oWndData SIZE 300, 100 PIXEL BARBUTTON ;
      ON CHANGE ( cItemText := oMemo:SaveAsRTF(), oBtnSave:Enable(), oMemo:Cargo := .T.,;
                  If( oTree:GetSelected() != nil, oTree:GetSelected():Cargo := cItemText,) )


Regards, saludos.
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: Necesito ayuda con Tree
Posted: Thu Jan 20, 2022 08:04 PM
Jo茫o

Code (fw): Select all Collapse
 @ 0, 205 RICHEDIT5 oMemo VAR cItemText OF oWndData SIZE 300, 100 PIXEL BARBUTTON ;
聽 聽 聽 ON CHANGE ( cItemText := oMemo:SaveAsRTF(), oBtnSave:Enable(), oMemo:Cargo := .T.,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 If( oTree:GetSelected() != nil, oTree:GetSelected():Cargo := cItemText,) ) 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽 
聽 聽oMemo:Cargo = .F. // it has not changed 聽 <----- Jo茫o, esto lo tienes?
FWH 20.12 BCC7