Page 1 of 1

oTree para video FUNCIONANDO

PostPosted: Fri Dec 15, 2017 10:58 pm
by Andrés González
Confieso no tener ni idea de como tratar los objetos Tree, nunca los he necesitado, pero he cogido un ejemplo del foro y es lo que estoy buscando para poder ver, añadir, borrar ficheros de video a mi aplicación. A ver si me podeis echar una mano en como seleccionar un fichero de los que muestra el tree.

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()
     Video(".\DAT\VID\"+"DOC000003"+".*")
Return nil


function Video()
    parameters x_file, x_msg

    local oDlg, oTree

    DEFAULT x_msg := "
Fichero no localizado..."

    DEFINE DIALOG oDlg SIZE 500, 340 TITLE "
Archivos de video relacionados"

   @ 0.5, 1 TREEVIEW oTree OF oDlg SIZE 100, 150

     @ 1, 27 BUTTON "
&Ver" OF oDlg SIZE 40, 12 ;
     ACTION (msginfo(oTree:GetSelected():cPrompt) , oDlg:End()) DEFAULT         //(WinExec("
CMD /C START /separate " + x_file,0)

     @ 3, 27 BUTTON "
&Añadir " OF oDlg SIZE 40, 12 ;
     ACTION (CopyFile(cGetFile("
*.mp4;*.mov;*.avi;*.mkv;*.flv;*.swf;*.m4v" ,"Selecciona fichero", , ".."), x_file ), oDlg:End())


   
     @ 5, 27 BUTTON "
&Borrar " OF oDlg SIZE 40, 12 ;
     ACTION oDlg:End() DEFAULT

   @ 7, 27 BUTTON "
&Abandonar" OF oDlg SIZE 40, 12 ;
     ACTION ( cValue := nil, oDlg:End() )


   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT FillTree( oTree, x_file )

return nil


function FillTree( oTree, cPath, oItem )

   local aInfo := Directory( cPath, "
D" )
   local n, oNode


     xbrowse (aInfo)
   for n = 1 to Len( aInfo )
      if ! aInfo[ n ][ 1 ] $ "
.,.."
         if oItem == nil
            oNode = oTree:Add( aInfo[ n ][ 1 ] )
         else
            oNode = oItem:Add( aInfo[ n ][ 1 ] )
         endif
         if "
D" $ aInfo[ n ][ 5 ]
            FillTree( oTree, cPath + aInfo[ n ][ 1 ] + "
\", oNode )
         endif
      endif
   next

return nil



Cómo puedo seleccionar el fichero que muestra y tengo seleccionado en el tree, he intentado algo como lo siguiente, pero no me da el correcto con el boton Ver:

msginfo(oTree:GetSelected():cPrompt)


Image

Re: oTree para video

PostPosted: Fri Dec 15, 2017 11:23 pm
by cnavarro
Creo que es algo más y no he entendido bien porque a mi si me muestra el item seleccionado
Image

Re: oTree para video

PostPosted: Sat Dec 16, 2017 12:15 am
by Andrés González
Gracias Cristobal ya me esta funcionando. Asi me muestra el video correctamente:

Code: Select all  Expand view
@ 1, 27 BUTTON "&Ver" OF oDlg SIZE 40, 12 ;
     ACTION ( WinExec("CMD /C START /separate " + cFilePath(x_file) + oTree:GetSelected():cPrompt,0) , oDlg:End()) DEFAULT

 

Re: oTree para video FUNCIONANDO

PostPosted: Sat Dec 16, 2017 10:14 am
by Andrés González
Ya funciona todo, sirve para añadir ficheros de video (solo uno por cada tipo) a un directorio y relacionarlo con un registro por ejemplo:


Code: Select all  Expand view
#include "FiveWin.ch"

function Main()
     //Video(".\DAT\VID\"+RTRIM(Q_T)+".*")
     Video(".\DAT\VID\"+"DOC000003"+".*")
Return nil


function Video()
    parameters x_file, x_msg

    local oDlg, oTree

    DEFAULT x_msg := "
Fichero no localizado..."

    DEFINE DIALOG oDlg SIZE 500, 340 TITLE "
Archivos de video relacionados"

   @ 0.5, 1 TREEVIEW oTree OF oDlg SIZE 100, 150

     @ 1, 27 BUTTON "
&Ver" OF oDlg SIZE 40, 12 ;
     ACTION ( WinExec("
CMD /C START /separate " + cFilePath(x_file) + oTree:GetSelected():cPrompt,0) , oDlg:End()) DEFAULT

     @ 3, 27 BUTTON "
&Añadir " OF oDlg SIZE 40, 12 ;
     ACTION ( AddVideo(x_file), oDlg:End() )

     @ 5, 27 BUTTON "
&Borrar " OF oDlg SIZE 40, 12 ;
     ACTION (iif(MsgYesNo("
Deseas eliminar el fichero"),filedelete(cFilePath(x_file) + oTree:GetSelected():cPrompt),),oDlg:End())

   @ 7, 27 BUTTON "
&Abandonar" OF oDlg SIZE 40, 12 ;
     ACTION ( cValue := nil, oDlg:End() )


   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT FillTree( oTree, x_file )

return nil


function FillTree( oTree, cPath, oItem )

   local aInfo := Directory( cPath, "
D" )
   local n, oNode


     xbrowse (aInfo)
   for n = 1 to Len( aInfo )
      if ! aInfo[ n ][ 1 ] $ "
.,.."
         if oItem == nil
            oNode = oTree:Add( aInfo[ n ][ 1 ] )
         else
            oNode = oItem:Add( aInfo[ n ][ 1 ] )
         endif
         if "
D" $ aInfo[ n ][ 5 ]
            FillTree( oTree, cPath + aInfo[ n ][ 1 ] + "
\", oNode )
         endif
      endif
   next

return nil

function AddVideo(x_file)

     Local cFile := cGetFile("
*.mp4;*.mov;*.avi;*.mkv;*.flv;*.swf;*.m4v" ,"Selecciona fichero", , "C:\")
            x_file := cFilePath(x_file) + cFileNoExt(x_file) + "
." + cFileExt(cFile)
            CopyFile(cFile, x_file)

Return nil




Image