download iPhone Photo connect to PC

download iPhone Photo connect to PC

Postby Jimmy » Fri Nov 25, 2022 5:10 am

hi,

when connect iPhone to PC it does not get a Drive-Letter.
you will "see" in Explorer a Icon so you can go to Folder

does some CODE already exist in Fivewin :?:

---

this CODE i use under HMG
Code: Select all  Expand view
PROCEDURE SearchDevice()
LOCAL cName, oItems
LOCAL i, iMax
LOCAL xParent

   nLevel := 1
   xParent := nLevel

   oShell := CreateObject( "shell.application" )
   IF NIL <> oShell
      oFolder := oShell:NameSpace( CSIDL_DRIVES )                     // 0x0011 // My Computer
      IF NIL <> oFolder
         oItems := oFolder:Items()
         iMax := oItems:Count
         FOR i := 1 TO iMax
            oFolderItem := oItems:Item( i - 1 )
            IF !EMPTY( oFolderItem )
               cName := UPPER( oFolderItem:name )
               IF cName = "DESKTOP"
                  LOOP
               ENDIF
               IF ASCAN( aFolder, { | e | e[ ID_Name ] = cName .AND. e[ ID_Level ] = nLevel } ) > 0
               ELSE
                  nElement ++
                  IPHONE.Tree_1.AddItem( cName, nLevel, nElement )    // nLevel := 1
                  IPHONE.Tree_1.CARGO( nElement ) := { cName, nLevel + 1 }                                                                  // next Level Action
                  IPHONE.Tree_1.NodeFlag( nElement ) := .T.
                  //  IPHONE.Tree_1.ImageIndex ( nElement ) := { IMAGE_FOLDER_UNCHECKED, IMAGE_FOLDER_UNCHECKED }
                  IPHONE.Tree_1.ImageIndex( nElement ) := IsRealDrive( oFolderItem )
                  AADD( aFolder, { oFolderItem, cName, nLevel + 1, xParent, nElement } )
                  AADD( aDevices, oFolderItem )

                  IF .NOT. oFolderItem:isFileSystem
                     AADD( aFileSys, i )
                  ENDIF
               ENDIF
            ENDIF
         NEXT
      ENDIF
   ENDIF
   DO EVENTS

RETURN

Image
i need to build a TREE using Fivewin
how to start using Fivewin, need Idea :idea:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: download iPhone Photo connect to PC

Postby Antonio Linares » Fri Nov 25, 2022 9:28 am

Dear Jimmy,

You can use the same code with almost no changes

Please review FWH\samples\testtree.prg

Also look for TTreeView in FWH\samples\*.prg there are many examples of its use
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

Re: download iPhone Photo connect to PC

Postby Jimmy » Fri Nov 25, 2022 9:43 am

hi Antonio,
Antonio Linares wrote:You can use the same code with almost no changes

Please review FWH\samples\testtree.prg

Also look for TTreeView in FWH\samples\*.prg there are many examples of its use

OK, thx

btw. when press 4th Button it crash
Application
===========
Path and name: C:\fwh\samples\testtree.exe (32 bits)
Size: 4,807,680 bytes
Compiler version: Harbour 3.2.0dev (r1801051438)
FiveWin version: FWH 22.03
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 26 secs
Error occurred at: 11/25/22, 10:38:57
Error description: Error BASE/1004 Message not found: TTREEVIEW:COLAPSEALL
Args:
[ 1] = O TTREEVIEW
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: download iPhone Photo connect to PC

Postby Antonio Linares » Fri Nov 25, 2022 9:52 am

Dear Jimmy,

many thanks for pointing it out

It is a typo in the code, it should use CollapseAll instead of ColapseAll

We have fixed it already
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

Re: download iPhone Photo connect to PC

Postby Antonio Linares » Fri Nov 25, 2022 9:54 am

Dear Jimmy,

FWH\samples\pim.prg is much more complete example to explore the capabilities of the trees :-)

Right click on the tree to see the options
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

Re: download iPhone Photo connect to PC

Postby Otto » Sat Nov 26, 2022 7:22 am

Dear Antonio,
it this program only working with harbour?
Best regards,
Otto

Code: Select all  Expand view

C:\FWH\samples\pim.prg(6) Error F0029  Can't open #include file: 'c:\harbour\contrib\xhb\hbxml.ch'
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: download iPhone Photo connect to PC

Postby Jimmy » Sun Nov 27, 2022 5:56 pm

hi Antonio,

i have found simple Sample \fwh\samples\elixir.prg which work as i need for CSIDL_DRIVES
now in Sample it use "recursiv" ReadFiles( cPath, oTreeView ) and got "Node-Flag" when have Sub-Folder

but when use CSIDL_DRIVES i do not want to "scan" all Drive and Sub-Folder ...
i want to DblClick on "Node" and than "build" Sub-Folder

---

i have begin to re-write HMG CODE for Fivewin and reach "Level 3" which mean ROOT -> FOLDER -> NEXT
Image

but i have to re-write also Concept of HMG to OOP of Fivewin

Code: Select all  Expand view
#IFDEF __HMG__
   IPHONE.Tree_1.DeleteAllItems
   IPHONE.Tree_1.AddItem( "This PC", 0, 1 )
   IPHONE.Tree_1.CARGO( 1 ) := { "ROOT", 2 }
#ELSE
   Tree_1:DeleteAll()
   oTreeItem := Tree_1:Add( "This PC", 0, 1 )
   oTreeItem:Cargo := { "ROOT", 2 }
#ENDIF

so it is a big Difference and a lot of CODE to "translate" for Fivewin

---

still not sure about Concept of Fivewin
in Sample elixir.prg "Cargo" use only String while HMG use Array with {String,nLevel}

these HMG Function are based on nLevel which seem missing under Fivewin

Code: Select all  Expand view
HMG Tree_1.ParentValue( nValue )  --> nValue | NIL 
HMG Tree_1.GetPathValue( nValue ) --> anPathValue | NIL 

so how is the OOP Way to find "Parent" or "Sub-Node" of a TreeItem under Fivewin :?:

p.s. i was told that most Android Smartphone also have no Drive-Letter and use Device like iPhone
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: download iPhone Photo connect to PC

Postby Antonio Linares » Mon Nov 28, 2022 9:19 am

Dear Jimmy,

oItem:oParent

oItem:aItems
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

Re: download iPhone Photo connect to PC

Postby Jimmy » Mon Nov 28, 2022 5:39 pm

hi Antonio

oItem:oParent
oItem:aItems

thx for Answer

i got to Step 3 and must use a Workaround which i don´t want.

Image
Problem : when click on Node it open Sub-Folder but click on Node in Sub-Folder fail ...
Workaround : open "all" Sub-Folder and navigate to "last"

my Workaround is Ok when have "just" 1 x Sub-Folder but it can be "more"

---
Code: Select all  Expand view
#include "FIVEWIN.CH"

* #define use_TGrid                    // do NOT enable for Standalone !

#define CSIDL_DRIVES                   0x0011
#define cDevice                        "APPLE IPHONE"       // change for Android

#define ID_Folder                      1
#define ID_Name                        2
#define ID_Level                       3
#define ID_Parent                      4
#define ID_Element                     5

STATIC oIPHONE
STATIC oTree_1
STATIC oButton_Target
STATIC oTargetDir
STATIC oButton_CopyHere
STATIC oButton_MoveHere
STATIC oFontDefault
STATIC oImageList
STATIC oShell, oFolder
STATIC oBrwCP
STATIC oGrid
STATIC oTreeLast

STATIC nLevel   := 0
STATIC nElement := 0
STATIC aFileSys := {}
STATIC aGridfiles := {"","","","","",""}
STATIC aFolder  := {}
STATIC lRecursiv := .F.

PROCEDURE MAIN(cPara)
LOCAL nFontSize := 20
LOCAL cTarget   := SPACE( 250 )
LOCAL nClrFore, nClrBack, lPixel := .T., lDesign := .F., nWidth := 200, nHeight := 600, cMsg := "", lCheckBoxes := .F., bChange, lEditable := .F.
LOCAL BFcolor, BGcolor
LOCAL aHeader := {}
LOCAL bAction := { || nil }
LOCAL nIcoLarge := 32
LOCAL nIcoSmall := 32

   IF !EMPTY(cPara)
      lRecursiv := .T.
   ENDIF


   DEFINE FONT oFontDefault NAME "TAHOMA" SIZE 0, - nFontSize
      ACTIVATE FONT oFontDefault
#IFDEF __HMG__
   END FONT
#ENDIF

   AADD( aHeader, { "Name", 200, 0, "C" } )
   AADD( aHeader, { "Size", 150, 1, "N" } )
   AADD( aHeader, { "Date", 110, 1, "D" } )
   AADD( aHeader, { "Time", 090, 1, "C" } )
   AADD( aHeader, { "Note", 250, 0, "C" } )

   aGridfiles := DIRECTORY("*.*","DHS")

   DEFINE WINDOW oIPHONE FROM 0, 0 TO 768, 1024 PIXEL TITLE "Device " ICON "A1MAIN"

#ifdef use_TGrid
      oGrid := TGrid() :New( 20, 220, bAction, oIPHONE, BFcolor, BGcolor, ;
                 lPixel, lDesign, 780, 600, cMsg, nIcoLarge, nIcoSmall )
      oGrid:aHeader := aHeader
      oGrid:aSource := aGridfiles
#endif

      oTree_1 := TTreeView() :New( 20, 10, oIPHONE, nClrFore, nClrBack, lPixel, lDesign, nWidth, nHeight, cMsg, lCheckBoxes, bChange, lEditable )

      oImageList := TImageList() :New()
      oImageList:Add( TBitmap() :Define( "folder",, oIPHONE ), ;
                      TBitmap() :Define( "fldmask",, oIPHONE ) )

      oTree_1:SetImageList( oImageList )

      oTree_1:bLDblClick = { || DoTreeAction( oTree_1:GetSelected() ) }

      @ 624, 010 BUTTON oButton_Target PROMPT "&Target Folder" SIZE 200, 30 PIXEL FONT oFontDefault OF oIPHONE
      @ 624, 220 GET oTargetDir VAR cTarget SIZE 780, 30 PIXEL FONT oFontDefault OF oIPHONE

      @ 660, 010 BUTTON oButton_CopyHere PROMPT "&CopyHere" SIZE 100, 30 PIXEL FONT oFontDefault OF oIPHONE
      @ 660, 110 BUTTON oButton_MoveHere PROMPT "&MoveHere" SIZE 100, 30 PIXEL FONT oFontDefault OF oIPHONE

#IFDEF __HMG__
   END WINDOW
#ENDIF

   ACTIVATE WINDOW oIPHONE ON INIT BuildRoot() VALID OnEnd() CENTER

RETURN

FUNCTION OnEnd()

RETURN .T.

STATIC PROCEDURE BuildRoot()

LOCAL oTreeItem

   oTree_1:DeleteAll()
   oTreeItem := oTree_1:Add( "This PC", 0, 0 )
   oTreeItem:Cargo := { "ROOT", 0 }

   nLevel := 1
   aFileSys := {}

   // now include at Start
   SearchDevice(oTreeItem)

   oTree_1:Expand()

#ifdef use_TGrid
   oGrid:InitTheListView()
#endif

RETURN

STATIC PROCEDURE SearchDevice(oTreeRoot)
LOCAL cName, oItems
LOCAL i, iMax
LOCAL oTreeItem
LOCAL oFolderItem

   nLevel := 2

   oShell := CreateObject( "shell.application" )
   IF NIL <> oShell
      oFolder := oShell:NameSpace( CSIDL_DRIVES )                     // 0x0011 // My Computer
      IF NIL <> oFolder
         oItems := oFolder:Items()
         iMax := oItems:Count
         FOR i := 1 TO iMax
            oFolderItem := oItems:Item( i - 1 )
            IF !EMPTY( oFolderItem )
               cName := UPPER( oFolderItem:name )
               IF cName = "DESKTOP"
                  LOOP
               ENDIF
               IF ASCAN( aFolder, { | e | e[ ID_Name ] = cName } ) > 0
               ELSE
                  nElement ++

                  oTreeItem := oTreeRoot:Add( cName, 0, nElement )
                  oTreeItem:Cargo := { cName, nLevel + 1 }            // next Level Action
                  AADD( aFolder, { oTreeItem, cName, nLevel + 1 } )

                  oTreeLast := oTreeItem

                  IF .NOT. oFolderItem:isFileSystem
                     AADD( aFileSys, i )
                  ENDIF
               ENDIF
            ENDIF
         NEXT
      ENDIF
   ENDIF

   Sysrefresh()

RETURN

STATIC PROCEDURE DoTreeAction(oTreeNext)
LOCAL xThis := oTreeNext:Cargo[1]
LOCAL cThis, oItems
LOCAL i, iMax
LOCAL oFolderItem
LOCAL oTreeItem
LOCAL nItem  := oTreeNext:Cargo[ 2 ]
LOCAL cPhone := oTreeNext:Cargo[ 1 ]

STATIC lIsExpand := .F.

   aGridfiles := {}

   IF xThis = cDevice
      IF oTreeNext:IsExpanded()
         oTreeNext:Collapse()
         lIsExpand := .F.
      ELSE
         IF NIL <> oFolder
            oItems := oFolder:Items()
            iMax := oItems:Count
            FOR i := 1 TO iMax
               oFolderItem := oItems:Item( i - 1 )
               IF !EMPTY( oFolderItem )
                  cThis := UPPER( oFolderItem:name )
                  IF cThis = UPPER( cPhone )
                     DoTreeRecursiv( oFolderItem, nLevel + 1, lRecursiv, oFolderItem:isFileSystem , oTreeNext )

                     oTreeNext:Expand()
                     lIsExpand := .T.

                     DO WHILE GoNext()
                          // get "last" Sub-Folder of TreeItem
                     ENDDO

                     ShowGrid()

                     // EXIT here
                     EXIT
                  ENDIF
               ENDIF
            NEXT
         ENDIF
      ENDIF
   ELSE
      IF lIsExpand = .T.
         MsgInfo(xThis)
         ShowGrid()
      ELSE
         MsgInfo(xThis +" is not a Device")
      ENDIF
   ENDIF
   Sysrefresh()

RETURN

STATIC PROCEDURE DoTreeRecursiv( xFolder, xLevel, xRecursiv, lisFileSys, oTreeNext)
LOCAL xThis, xItems
LOCAL ii , iMax, xFolderItem
LOCAL c_Name, c_Size, c_Date, c_Attr, c_Type
LOCAL cTarget
LOCAL oTreeItem
LOCAL oItemParent

   DEFAULT lisFileSys := .T.

   IF NIL <> xFolder
      nLevel := xLevel
      xItems := xFolder:GetFolder:Items()
      iMax := xItems:Count
      FOR ii := 1 TO iMax
         xFolderItem := xItems:Item( ii - 1 )
         IF !EMPTY( xFolderItem )
            IF xFolderItem:IsLink
               LOOP
            ENDIF
            IF xFolderItem:IsFolder                                // is it a folder
               xThis := UPPER( xFolderItem:name )

               IF ASCAN( aFolder, { | e | e[ ID_Name ] = xThis } ) > 0
               ELSE

               // search for Child and its Parent
                  nElement ++

                  oTreeItem := oTreeNext:Add( xThis, 0, xLevel )
                  oTreeItem:Cargo := { xThis, xLevel }             // next Level Action
                  oTreeNext:Expand()
                  AADD( aFolder, { oTreeItem, xThis, nLevel + 1 } )

                  // do NOT want to use it recursiv
                  IF xRecursiv = .T.
                     oTreeLast := oTreeItem
                     DoTreeRecursiv( xFolderItem, xLevel + 1, xRecursiv, lisFileSys, oTreeItem )
                  ENDIF
               ENDIF
            ELSE
               c_Name := xFolderItem:name
               c_Size := xFolderItem:Size
               c_Date := xFolderItem:ModifyDate
               c_Type := xFolderItem:Type
               c_Attr := ""
               AADD( aGridfiles, { c_Name, c_Size, c_Date, c_Attr, c_Type, LTRIM( STR( xLevel + 1 ) ) } )
            ENDIF
         ENDIF
      NEXT
   ENDIF

RETURN

STATIC FUNCTION GoNext()
local oSelItem := oTree_1:GetSelected(), lStop := .F., oNextItem
local lRet := .T.

   oTree_1:Scan( { | oItem | If( oItem:hItem == oSelItem:hItem, lStop := .T.,),;
                       If( lStop .and. oItem:hItem != oSelItem:hItem, ( oNextItem := oItem, .T. ), .F. ) } )

   if oNextItem != nil
      oTree_1:Select( oNextItem )
      if oNextItem:Cargo[2] = oTreeLast:Cargo[2]
         lRet := .F.
      endif
   else
      lRet := .F.
   endif

return lRet

STATIC PROCEDURE ShowGrid()
#ifdef use_TGrid
   oGrid:aSource := aGridfiles
   oGrid:ClearAndFill( oIPHONE )
#endif
RETURN

************************** include in DUALGRID.PRG **************************


#ifdef use_TGrid
FUNCTION EndwithSlash( cString )
LOCAL nPosi

   IF !EMPTY( cString )
      nPosi := RAT( "\", cString )
      IF nPosi = LEN( cString )
      ELSE
         cString += "
\"
      ENDIF
      cString := STRTRAN( cString, "
\\", "\", 3 )
   ENDIF

RETURN cString

FUNCTION CompareFile( aX, aY, lUp )
LOCAL cName1, cName2
LOCAL lRet

   DEFAULT lUp := .T.

   cName1 := LOWER( FindExt( aX ) + FindName( aX ) )
   cName2 := LOWER( FindExt( aY ) + FindName( aY ) )

   IF lUp = .T.
      lRet := cName1 < cName2
   ELSE
      lRet := cName1 > cName2
   ENDIF

RETURN ( lRet )

FUNCTION FindName( filename )
LOCAL nPosi := RAT( "
.", filename )
RETURN SUBSTR( filename, 1, nPosi - 1 )

FUNCTION FindExt( filename )
LOCAL nPosi := RAT( "
.", filename )
RETURN UPPER( SUBSTR( filename, nPosi + 1, LEN( filename ) ) )

PROCEDURE SayBar( cText, nPart )
RETURN

#include "
TGRID.PRG"
#include "
HB_FUNC.PRG"

#endif
*

Sample does not include CLASS TGrid or HB_FUNC but work as Standalone to show my Problem
i made it for my iPhone so so might change it for Android (if you can see it in Windows Explorer)

compile / run Sample
only Folder "APPLE IPHONE" is valid to open (see about Android)
when click on "APPLE IPHONE" it will open next Sub-Folder
but when click on Sub-Folder nothing happens :(

start again with "any Parameter"
click on "APPLE IPHONE"
now hole Sub-Folder Tree will open
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: download iPhone Photo connect to PC

Postby Antonio Linares » Tue Nov 29, 2022 8:45 am

Dear Jimmy,

Could you reproduce it using FWH\samples\testtree.prg or pim.prg ?

I have built your example and it seems to work fine but I get no subnodes
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

Re: download iPhone Photo connect to PC

Postby Jimmy » Wed Nov 30, 2022 3:37 pm

hi Antonio,

have change Concept and now it work :)

my "Problem" was to handle 2 x 2 Object : Fivewin TTreeView/TTVItem and Windows Folder/Folderitem

when work with TTreeView/TTVItemto build "static" Tree all work
but when add Child "dynamic" i have to use Folder/Folderitem when work with Device

now i "store" FolderItem in CARGO of TreeItem so i got right Relation of TREE and (virtual) Folder Structure
so here now working Sample to open Sub-Folder "on fly"

Code: Select all  Expand view
*#include "FIVEWIN.CH"

* #define use_TGrid                      // do NOT enable for Standalone !
#define CSIDL_DRIVES                   0x0011
#define cDevice                        "APPLE IPHONE" // change for Android

#define FOF_SIMPLEPROGRESS             0x0100
#define LVIS_FOCUSED                   0x01
#define LVIS_SELECTED                  0x02

#define ID_Folder                      1
#define ID_Name                        2
#define ID_Level                       3
#define ID_Parent                      4
#define ID_Element                     5

STATIC oIPHONE
STATIC oTree_1
STATIC oButton_Target
STATIC oTargetDir
STATIC oButton_CopyHere
STATIC oButton_MoveHere
STATIC oFontDefault
STATIC oImageList
STATIC oShell, oFolder
STATIC oBrwCP
STATIC oGrid
STATIC oTreeLast

STATIC nLevel     := 0
STATIC nElement   := 0
STATIC aFileSys   := {}
STATIC aGridfiles := { "", "", "", "", "", "" }
STATIC aFolder    := {}
STATIC lRecursiv  := .F.
STATIC c_Target

*+--------------------------------------------------------------------
*+
*+    Procedure MAIN()
*+
*+--------------------------------------------------------------------
*+
PROCEDURE MAIN( cPara )

LOCAL nFontSize := 20
LOCAL nClrFore, nClrBack, lPixel := .T., lDesign := .F., nWidth := 200, nHeight := 600, cMsg := "", lCheckBoxes := .F., bChange, lEditable := .F.
LOCAL BFcolor, BGcolor
LOCAL aHeader   := {}
LOCAL bAction   := { || nil }
LOCAL nIcoLarge := 32
LOCAL nIcoSmall := 32
LOCAL lCheckbox := .T.

   c_Target := SPACE( 250 )

   IF !EMPTY( cPara )
      lRecursiv := .T.
   ENDIF

   DEFINE FONT oFontDefault NAME "TAHOMA" SIZE 0, - nFontSize
      ACTIVATE FONT oFontDefault
#IFDEF __HMG__
   END FONT
#ENDIF

   AADD( aHeader, { "Name", 200, 0, "C" } )
   AADD( aHeader, { "Size", 150, 1, "N" } )
   AADD( aHeader, { "Date", 110, 1, "D" } )
   AADD( aHeader, { "Time", 090, 1, "C" } )
   AADD( aHeader, { "Note", 250, 0, "C" } )

   aGridfiles := DIRECTORY( "*.*", "DHS" )

   DEFINE WINDOW oIPHONE FROM 0, 0 TO 768, 1024 PIXEL TITLE "Device " ICON "A1MAIN"

#ifdef use_TGrid
      oGrid := TGrid() :New( 20, 220, bAction, oIPHONE, BFcolor, BGcolor, ;
                       lPixel, lDesign, 780, 600, cMsg, nIcoLarge, nIcoSmall, lCheckbox )
      oGrid:aHeader := aHeader
      oGrid:aSource := aGridfiles
#endif

      oTree_1 := TTreeView() :New( 20, 10, oIPHONE, nClrFore, nClrBack, lPixel, lDesign, nWidth, nHeight, cMsg, lCheckBoxes, bChange, lEditable )

      oImageList := TImageList() :New()
      oImageList:Add( TBitmap() :Define( "folder",, oIPHONE ), ;
                      TBitmap() :Define( "fldmask",, oIPHONE ) )

      oTree_1:SetImageList( oImageList )

      oTree_1:bLDblClick := { || DoTreeAction( oTree_1:GetSelected() ) }
      oTree_1:bChanged := { || ShowGrid() }

      @ 624, 010 BUTTON oButton_Target PROMPT "&Target Folder" SIZE 200, 30 PIXEL FONT oFontDefault ACTION GetTargetFolder() OF oIPHONE
      @ 624, 220 GET oTargetDir VAR c_Target SIZE 780, 30 PIXEL FONT oFontDefault OF oIPHONE

      @ 660, 010 BUTTON oButton_CopyHere PROMPT "&CopyHere" SIZE 100, 30 PIXEL FONT oFontDefault ACTION Start_CopyHere( .F. ) OF oIPHONE
      @ 660, 110 BUTTON oButton_MoveHere PROMPT "&MoveHere" SIZE 100, 30 PIXEL FONT oFontDefault ACTION Start_CopyHere( .T. ) OF oIPHONE

      oButton_CopyHere:hide()
      oButton_MoveHere:hide()
#IFDEF __HMG__
   END WINDOW
#ENDIF

   ACTIVATE WINDOW oIPHONE ON INIT BuildRoot() VALID OnEnd() CENTER

RETURN

*+--------------------------------------------------------------------
*+
*+    Function OnEnd()
*+
*+    Called from ( iphone.prg )   1 - procedure iphonewin()
*+                ( phone3.prg )   1 - procedure main()
*+
*+--------------------------------------------------------------------
*+
FUNCTION OnEnd()

RETURN .T.

*+--------------------------------------------------------------------
*+
*+    Static Procedure DoTreeAction()
*+
*+    Called from ( phone3.prg )   1 - procedure main()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE DoTreeAction( oTreeNext )

LOCAL cThis       := oTreeNext:Cargo[ 1 ]
LOCAL nItem       := oTreeNext:Cargo[ 2 ]
LOCAL oFolderItem := oTreeNext:Cargo[ 3 ]
LOCAL aSelect, xFolder, xName, xLevel, xParent, xElement
LOCAL nPosi, oError
LOCAL bSaveError  := ERRORBLOCK( { | oErr | BREAK( oErr ) } )

   aGridfiles := {}
   DO CASE
      CASE nLevel = 0
         BuildRoot()
      CASE nLevel = 1
         SearchDevice()
      CASE nLevel = 2
         SelectDevice()

      OTHERWISE

         IF !EMPTY( aFolder ) .AND. !EMPTY( cThis )
            nPosi := ASCAN( aFolder, { | e | e[ ID_Name ] = UPPER( cThis ) } )
            //  .AND. e[ ID_Parent ] = nParent
            IF nPosi > 0
               aSelect := aFolder[ nPosi ]

               xFolder := aSelect[ ID_Folder ]
               xName := aSelect[ ID_Name ]
               xLevel := aSelect[ ID_Level ]

               DoTreeRecursiv( oFolderItem, xLevel + 1, .F., .F., .F., .F., oTreeNext )

               ShowGrid()
            ENDIF
         ENDIF
   ENDCASE
RETURN

*+--------------------------------------------------------------------
*+
*+    Static Procedure BuildRoot()
*+
*+    Called from ( phone3.prg )   1 - procedure main()
*+                                   1 - static procedure dotreeaction()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE BuildRoot()

LOCAL oTreeItem

   oTree_1:DeleteAll()
   oTreeItem := oTree_1:Add( "This PC", 0, 0 )
   oTreeItem:Cargo := { "ROOT", 0, 0 }

   nLevel := 1
   aFileSys := {}
   aFolder := {}
   AADD( aFolder, { NIL, "This PC", 1, nElement } )

   // now include at Start
   SearchDevice( oTreeItem )

   oTree_1:Expand()

#ifdef use_TGrid
   oGrid:InitTheListView()
#endif

RETURN

*+--------------------------------------------------------------------
*+
*+    Static Procedure SearchDevice()
*+
*+    Called from ( phone3.prg )   1 - static procedure dotreeaction()
*+                                   1 - static procedure buildroot()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE SearchDevice( oTreeRoot )

LOCAL cName, oItems
LOCAL i, iMax
LOCAL oTreeItem
LOCAL oFolderItem

   nLevel := 2

   oShell := CreateObject( "shell.application" )
   IF NIL <> oShell
      oFolder := oShell:NameSpace( CSIDL_DRIVES )                     // 0x0011 // My Computer
      IF NIL <> oFolder
         // https://learn.microsoft.com/de-de/windo ... lder-items
         oItems := oFolder:Items()

         iMax := oItems:Count
         FOR i := 1 TO iMax
            // https://learn.microsoft.com/de-de/windo ... folderitem
            oFolderItem := oItems:Item( i - 1 )

            IF !EMPTY( oFolderItem )
               cName := UPPER( oFolderItem:name )
               IF cName = "DESKTOP"
                  LOOP
               ENDIF
               IF ASCAN( aFolder, { | e | e[ ID_Name ] = cName } ) > 0
               ELSE
                  nElement ++

                  oTreeItem := oTreeRoot:Add( cName, 0, nElement )
                  oTreeItem:Cargo := { cName, nLevel, oFolderItem }   // next Level Action
                  AADD( aFolder, { oTreeItem, cName, nLevel, oFolder } )

                  oTreeLast := oTreeItem

                  IF .NOT. oFolderItem:isFileSystem
                     AADD( aFileSys, i )
                  ENDIF
               ENDIF
            ENDIF
         NEXT
      ENDIF
   ENDIF

   Sysrefresh()

RETURN

*+--------------------------------------------------------------------
*+
*+    Static Procedure SelectDevice()
*+
*+    Called from ( phone3.prg )   1 - static procedure dotreeaction()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE SelectDevice()

LOCAL cThis, oItems
LOCAL i, iMax, xParent := 0
LOCAL nItem
LOCAL oFolderItem

   nLevel := 3
   IF NIL <> oFolder
      oItems := oFolder:Items()
      iMax := oItems:Count
      FOR i := 1 TO iMax
         oFolderItem := oItems:Item( i - 1 )
         IF !EMPTY( oFolderItem )
            // https://learn.microsoft.com/de-de/windo ... ritem-name
            cThis := UPPER( oFolderItem:name )

            IF UPPER( cThis ) = cDevice
               // EXIT here
               EXIT
            ENDIF
         ENDIF
      NEXT
   ENDIF

   Sysrefresh()

RETURN

*+--------------------------------------------------------------------
*+
*+    Static Procedure DoTreeRecursiv()
*+
*+    Called from ( phone3.prg )   1 - static procedure dotreeaction()
*+                                   1 - static procedure dotreerecursiv()
*+                                   1 - static procedure start_copyhere()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE DoTreeRecursiv( xFolder, xLevel, xRecursiv, lTransfer, lMove, lisFileSys, oTreeNext )

LOCAL xThis, xItems
LOCAL ii, iMax, xFolderItem
LOCAL c_Name, c_Size, c_Date, c_Attr, c_Type
LOCAL cTarget     := c_Target
LOCAL oTreeItem
LOCAL oItemParent

   DEFAULT lTransfer := .F.
   DEFAULT lisFileSys := .T.

   IF NIL <> xFolder

      nLevel := xLevel

      //  https://learn.microsoft.com/en-us/windows/win32/shell/folderitem-getfolder
      xItems := xFolder:GetFolder:Items()

      IF lTransfer = .T.
#ifdef use_TGrid
         DoCopySingle( xItems, cTarget, lMove )
#endif
      ELSE

         iMax := xItems:Count
         FOR ii := 1 TO iMax
            // https://learn.microsoft.com/de-de/windo ... folderitem
            xFolderItem := xItems:Item( ii - 1 )

            IF !EMPTY( xFolderItem )
               // https://learn.microsoft.com/de-de/windo ... tem-islink
               IF xFolderItem:IsLink
                  LOOP
               ENDIF

               // https://learn.microsoft.com/de-de/windo ... m-isfolder
               IF xFolderItem:IsFolder                                // is it a folder
                  // https://learn.microsoft.com/de-de/windo ... ritem-name
                  xThis := UPPER( xFolderItem:name )

                  IF ASCAN( aFolder, { | e | e[ ID_Name ] = xThis } ) > 0
                  ELSE

                     nElement ++

                     oTreeItem := oTreeNext:Add( xThis, 0, xLevel )
                     oTreeItem:Cargo := { xThis, xLevel, xFolderItem }                                                                      // next Level Action
                     oTreeNext:Expand()

                     AADD( aFolder, { oTreeItem, xThis, nLevel + 1, xFolder } )

                     // not used here
                     IF xRecursiv = .T.
                        oTreeLast := oTreeItem
                        DoTreeRecursiv( xFolderItem, xLevel + 1, xRecursiv, .F., .F., lisFileSys, oTreeNext )
                     ENDIF
                  ENDIF
               ELSE
                  c_Name := xFolderItem:name
                  c_Size := xFolderItem:Size
                  c_Date := xFolderItem:ModifyDate
                  c_Type := xFolderItem:Type
                  c_Attr := ""
                  AADD( aGridfiles, { c_Name, c_Size, c_Date, c_Attr, c_Type, LTRIM( STR( xLevel + 1 ) ) } )
               ENDIF
            ENDIF
         NEXT
      ENDIF
   ENDIF

RETURN

*+--------------------------------------------------------------------
*+
*+    Static Procedure GetTargetFolder()
*+
*+    Called from ( phone3.prg )   1 - procedure main()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE GetTargetFolder()

LOCAL cFolder := cGETFOLDER( "Get Target Folder", c_Target )

   IF !EMPTY( cFolder )
      c_Target := EndwithSlash( cFolder )
      oTargetDir:Refresh()
   ENDIF
RETURN

*+--------------------------------------------------------------------
*+
*+    Static Procedure ShowGrid()
*+
*+    Called from ( phone3.prg )   1 - procedure main()
*+                                   1 - static procedure dotreeaction()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE ShowGrid()

   oButton_CopyHere:Show()
   oButton_MoveHere:Show()

#ifdef use_TGrid
   oGrid:aSource := aGridfiles
   oGrid:ClearAndFill( oIPHONE )
#endif
RETURN

*+--------------------------------------------------------------------
*+
*+    Static Procedure Start_CopyHere()
*+
*+    Called from ( phone3.prg )   2 - procedure main()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE Start_CopyHere( lMove )

LOCAL nPosi
LOCAL nItem  := oTreeLast:Cargo[ 2 ]                                  // IPHONE.Tree_1.Value
LOCAL cThis  := oTreeLast:Cargo[ 1 ]                                  // TRIM( IPHONE.Tree_1.Item( nItem ) )
LOCAL oFItem := oTreeLast:Cargo[ 3 ]

LOCAL lTransfer := .T.
LOCAL aSelect, xFolder, xName, xLevel, xParent, xElement, xOther

   IF !EMPTY( aGridfiles )
      IF nItem > 0
         aSelect := aFolder[ nItem ]

         xFolder := aSelect[ ID_Folder ]
         xName := aSelect[ ID_Name ]
         xLevel := aSelect[ ID_Level ]
         xOther := aSelect[ 4 ]

         fwlog hb_valToExp( xFolder )                                 // Folder-Object
         fwlog hb_valToExp( xName )                                   // OK String
         fwlog hb_valToExp( xLevel )                                  // OK Number
         fwlog hb_valToExp( xOther )                                  // OLE
         fwlog hb_valToExp( oTreeLast )                               // TTVITEM
         fwlog hb_valToExp( oFItem )                                  // TOLEAUTO

         DO CASE
            CASE xFolder:IsDerivedFrom( "TTreeItem" )
               FWLOG "TTreeItem"
            CASE xFolder:IsDerivedFrom( "TTreeView" )
               FWLOG "TTreeView"
            CASE xFolder:IsDerivedFrom( "TTVItem" )
               FWLOG "TTVItem"
            OTHERWISE
         ENDCASE

         DoTreeRecursiv( oFItem, xLevel, .F., lTransfer, lMove ) // "TOLEAUTO"
         * DoTreeRecursiv( xFolder, xLevel, .F., lTransfer, lMove )     // "TTVItem"

      ENDIF
   ENDIF
   sysrefresh()

RETURN

*+--------------------------------------------------------------------
*+
*+    Static Function GoNext()
*+
*+--------------------------------------------------------------------
*+
STATIC FUNCTION GoNext()

LOCAL oSelItem := oTree_1:GetSelected(), lStop := .F., oNextItem
LOCAL lRet     := .T.

   oTree_1:Scan( { | oItem | IF( oItem:hItem == oSelItem:hItem, lStop := .T., ), ;
                   IF( lStop .AND. oItem:hItem != oSelItem:hItem, ( oNextItem := oItem, .T. ), .F. ) } )

   IF oNextItem != nil
      oTree_1:Select( oNextItem )
      IF oNextItem:Cargo[ 2 ] = oTreeLast:Cargo[ 2 ]
         lRet := .F.
      ENDIF
   ELSE
      lRet := .F.
   ENDIF

RETURN lRet

*+--------------------------------------------------------------------
*+
*+    Static Function EndwithSlash()
*+
*+    Called from ( phone3.prg )   1 - static procedure gettargetfolder()
*+
*+--------------------------------------------------------------------
*+
STATIC FUNCTION EndwithSlash( cString )

LOCAL nPosi

   IF !EMPTY( cString )
      nPosi := RAT( "\", cString )
      IF nPosi = LEN( cString )
      ELSE
         cString += "
\"
      ENDIF
      cString := STRTRAN( cString, "
\\", "\", 3 )
   ENDIF

RETURN cString

// ************************* include in DUALGRID.PRG **************************

#ifdef use_TGrid

*+--------------------------------------------------------------------
*+
*+    Static Procedure DoCopySingle()
*+
*+    Called from ( phone3.prg )   1 - static procedure dotreerecursiv()
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE DoCopySingle( oDirFolder, cTarget, lMove )

LOCAL hGrid   := oGrid:hwnd                                           // GetControlHandle( "
Grid_1", "IPHONE" )
LOCAL oNewSH  := CreateObject( "
Shell.Application" )
LOCAL oTarget := oNewSH:NameSpace( cTarget )
LOCAL xFlag   := FOF_SIMPLEPROGRESS
LOCAL nState  := hb_BitOr( LVIS_SELECTED, LVIS_FOCUSED )
LOCAL nMask   := hb_BitOr( LVIS_SELECTED, LVIS_FOCUSED )
LOCAL aFiles  := {}
LOCAL oFile, cFile, xCount, nCount
LOCAL i, iMax, nSkip := 0

   DEFAULT lMove := .F.

   iMax := oDirFolder:Count
   FOR i := 1 TO iMax

      SYSrefresh()

      // if Checkbox is marked
      //       IF IPHONE.Grid_1.CheckBoxItem( i ) = .T.

      // get Item Object
      oFile := oDirFolder:Item( i - 1 )

      IF lMove = .T.
         // move single Object file
         // https://learn.microsoft.com/de-de/windo ... r-movehere
         oTarget:MoveHere( oFile, xFlag )
      ELSE
         // copy single Object file
         // https://learn.microsoft.com/de-de/windo ... r-copyhere
         oTarget:CopyHere( oFile, xFlag )
      ENDIF

      // wait until all files are written
      xCount := 0
      DO WHILE .T.
         // compare if file is written
         nCount := oTarget:items() :Count()
         IF nCount + nSkip >= i
            EXIT
         ENDIF
         hb_idleSleep( 0.1 )
         xCount ++
         IF xCount > 50
            EXIT
         ENDIF
      ENDDO

      // scroll GRID if need
      LV_SETITEMSTATE( hGrid, i, nState, nMask )
      LV_EnsureVisible( hGrid, i )

      //       ELSE
      //          // Skip un-maked
      //          nSkip ++
      //       ENDIF
   NEXT
   // clean up
   hb_idleSleep( 0.5 )

   oTarget := NIL
   oNewSH := NIL

   SYSrefresh()

RETURN

*+--------------------------------------------------------------------
*+
*+    Static Function CompareFile()
*+
*+
*+--------------------------------------------------------------------
*+
STATIC FUNCTION CompareFile( aX, aY, lUp )

LOCAL cName1, cName2
LOCAL lRet

   DEFAULT lUp := .T.

   cName1 := LOWER( FindExt( aX ) + FindName( aX ) )
   cName2 := LOWER( FindExt( aY ) + FindName( aY ) )

   IF lUp = .T.
      lRet := cName1 < cName2
   ELSE
      lRet := cName1 > cName2
   ENDIF

RETURN ( lRet )

*+--------------------------------------------------------------------
*+
*+    Static Function FindName()
*+
*+    Called from ( phone3.prg )   2 - static function comparefile()
*+
*+--------------------------------------------------------------------
*+
STATIC FUNCTION FindName( filename )

LOCAL nPosi := RAT( "
.", filename )
RETURN SUBSTR( filename, 1, nPosi - 1 )

*+--------------------------------------------------------------------
*+
*+    Static Function FindExt()
*+
*+    Called from ( phone3.prg )   2 - static function comparefile()
*+
*+--------------------------------------------------------------------
*+
STATIC FUNCTION FindExt( filename )

LOCAL nPosi := RAT( "
.", filename )
RETURN UPPER( SUBSTR( filename, nPosi + 1, LEN( filename ) ) )

*+--------------------------------------------------------------------
*+
*+    Static Procedure SayBar()
*+
*+
*+--------------------------------------------------------------------
*+
STATIC PROCEDURE SayBar( cText, nPart )

RETURN

#include "
TGRID.PRG"
#include "
HB_FUNC.PRG"

#endif

*+ EOF: PHONE3.PRG

... but still need to "optimize" (DblCkick/Click to expand)
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: download iPhone Photo connect to PC

Postby Antonio Linares » Thu Dec 01, 2022 9:24 am

Dear Jimmy,

Your example seems to work fine here

What do you need to enhance ? How to test it ?

many thanks
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

Re: download iPhone Photo connect to PC

Postby Jimmy » Thu Dec 01, 2022 1:19 pm

hi Antonio,

CODE seems to work but there are some "small" Thing like Dblclick which did not "expand" so i need another Dblclick

full Sample need CLASS TGrid() (or XBROWSE) to work which still is "under construction"
but Sample can "show" Device "Path"
Image
not sure about Android
try to change this line for Android
Code: Select all  Expand view
#define cDevice                        "APPLE IPHONE" // change for Android
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: download iPhone Photo connect to PC

Postby Antonio Linares » Thu Dec 01, 2022 5:22 pm

Dear Jimmy,

In FWH\samples\testtree.prg double click works fine

so it may be something you are doing in your code...
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

Re: download iPhone Photo connect to PC

Postby Jimmy » Thu Dec 01, 2022 6:33 pm

hi Antonio,
Antonio Linares wrote:so it may be something you are doing in your code...

Yes, 2nd Dblclick work as expect
i have to figure out why my 1st Dblclick is not working as expect
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests