Double directory explorer

User projects written in or related to FreeBASIC.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Postby bcohio2001 » Oct 25, 2010 21:03

BastetFurry wrote:@bcohio2001:
I havent a Windows open to test it, could you please post some screenys of this orthodox file manager of yours? :)
(Yeah, they are all called like that, old Uncle NortonCommander, Total Commander, Servant Salamander, FAR-Manager, ....)

Screen shot at web site...see first post

v0.4 10/25/2010
Added:
-- Trash bin
---- Still not sure on folder restoring and restoring files to folders that no longer exist.

Working on:
-- Sort routine for listview header click, still can not get logics right...."highly illogical, Jim."

Want to add:
-- Trapping events on the file listing:
---- Open/View file when user hits enter key
-- Find default editors for files -- Open With.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Up to version 1

Postby bcohio2001 » Jun 10, 2011 0:08

Moving up in the world!!

v1.0 06/09/2011
Added:
-- FTP
-- Manual for use. Not a very good one.

************************
Working on:
-- Sort routine for listview header click, still can not get logics right...."highly illogical, Jim."

Want to add:
-- Trapping events on the file listing:
---- Open/View file when user hits enter key
-- On screen logging of FTP events.
-- Progress bar or some other notification during long directory file manipulation.
-- Make my own -- Open With.

Unsure of:
-- FTP functioning.
-- Restoring from Trash Bin of files to folders that no longer exists. Or restoring whole folders.
Loe
Posts: 323
Joined: Apr 30, 2006 14:49

Postby Loe » Jun 10, 2011 8:08

Hi Brian,
about listview sort, there is win api command

Code: Select all

BOOL ListView_SortItems(

    HWND hwnd,    
    PFNLVCOMPARE pfnCompare,    
    LPARAM lParamSort   
   );

following is typical compare function, and rest after compared

Code: Select all

FUNCTION compare(BYVAL lParam1 AS LONG, BYVAL lParam2 AS LONG, BYVAL lParamsort AS LONG) AS Integer
    dim value1 AS zstring * 300
    dim value2 AS zstring * 300
    dim j as integer

    FUNCTION = 0

    value1 = LVGetValue(hList, lParam1, lParamsort)
    value2 = LVGetValue(hList, lParam2, lParamsort)
    SELECT CASE lviewSort
        CASE 0 'ascending
        j = 1
        CASE ELSE 'descending
        j = -1
    END SELECT
    IF value1 < value2 THEN
        FUNCTION = -1 * j
    ELSEIF value1 = value2 THEN
        FUNCTION = 0
    ELSE
        FUNCTION = 1 * j
    END IF
END Function

SUB ResetLParam(ByRef hList AS LONG)
    dim i AS LONG
    dim recs AS LONG
    dim lvi AS LV_ITEM
    dim x AS LONG

    lvi.mask = LVIF_PARAM
    lvi.iSubItem = 0
    recs = sendmessage(hlist,lvm_GetItemCount,0,0)
    FOR i = 0 TO recs - 1
        lvi.iItem = i
        x = SendMessage(hList,LVM_GetItem,0,@lvi)
        lvi.lParam = lvi.iItem
        x = SendMessage(hList,LVM_SetItem,0,@lvi)
    NEXT
END SUB 

add this in your notify event, to receive click on Listview header

Code: Select all

Function dlgList_OnNotify(Byval hWin as hwnd,Byval lCtlID as long,Byval lpNMHDR as NMHDR ptr,Byref lresult as long)as Integer
   Dim pnmlv As NMLISTVIEW Ptr
   Dim item As Integer
   SELECT CASE lpNMHdr->idFrom
      CASE idc_LSV1
      pNMLV=lpnmhdr
      SELECT CASE pNmlv->hdr.Code
         Case LVN_COLUMNCLICK            
            IF pNmLv->iSubItem <> -1 THEN
               'toggle ascending/descending
               lviewSort = NOT lviewSort
               ListView_SortItems(hList,procPTR(compare), pNmLv->iSubItem)
               ResetLParam hList
            END If            
        End select
   End select           
End Function
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Postby bcohio2001 » Jun 11, 2011 19:33

Maybe I should have clarified about "logic".
I have the "notify" in my dlgproc and have ListView_SortItems pointing to my SortFunc().

Here is what I am using
Listview columns are "Test.txt|Txt|12/19/2011 12:15PM|1.5 KB|DAHSR"
File Name, Extention/DIR, Date and time of file, Size, Attributes

Code: Select all

Function Sort_Dir(L As HWND, One As Integer, Two As Integer) As Integer
   Dim As Integer Count
   Dim As String T1,T2
   '
   T1 = LVGetValue(L,One,1)
   T2 = LVGetValue(L,Two,1)
   'count how many are folders
   If T1 = "DIR" Then
      Count += 1
   EndIf
   If T2 = "DIR" Then
      Count += 1
   EndIf
   'return 0 if neither or both are folders
   If Count = 0 Or Count = 2 Then
      Return 0
   EndIf
   'return 1 if One is folder
   'return 2 if second is folder
   If T1 = "DIR" Then
      Return 1
   Else
      Return 2
   EndIf
End Function

Function SortUDNE(S1 As String,S2 As String,UD As BOOL) As Integer
   'stands for sort Up or Down and strings are Not Equal
   'if my logic is wrong, can fix in one spot
   DebugMe ""
   DebugMe "In SortUDNE"
   DebugMe "String 1 is ("+S1+")"
   DebugMe "String 2 is ("+S2+")"
   If UD Then
      DebugMe "Accending"
      If S1 < S2 Then
         DebugMe "S1 should be first"
         DebugMe ""
         Return -1
      Else
         DebugMe "S2 should be first"
         DebugMe ""
         Return 1
      EndIf
   Else
      DebugMe "Decending"
      If S1 < S2 Then
         DebugMe "S2 should be first"
         DebugMe ""
         Return 1
      Else
         DebugMe "S1 should be first"
         DebugMe ""
         Return -1
      EndIf
   EndIf
End Function

'this is the callback function for the ListView_SortItems
Function SortFunc(I1 As LPARAM, I2 As LPARAM, C As LPARAM) As Integer
   'Return a negative value if the first item should precede the second,
   'a positive value if the first item should follow the second,
   'Or zero if the two items are equivalent.
   '
   Dim As HWND L
   Dim As String Str1, Str2, LookP
   Dim As BOOL SortUp
   Dim As Integer ReturnThis
   Dim As Double V1,V2
   '
   If C > 9 Then
      C -= 10 'Column
      L = FBottom 'bottom listview
      SortUp = LastSortAccendBottom
      LookP = wtBottom
   Else
      'C is correct
      L = FTop
      SortUp = LastSortAccendTop
      LookP = wtTop
   EndIf
   'I1 'row of LV
   'I2 'Row of LV
   'Name/type/date/size/attr
   Str1 = LCase(LVGetValue(L,I1,C))
   Str2 = LCase(LVGetValue(L,I2,C))
   Select Case As Const C
      Case 0
         'sort by name
         DebugMe "Sort by name"
         ReturnThis = Sort_Dir(L,I1,I2)
         If ReturnThis = 1 Then
            'one of them is a folder
            Return -1
         EndIf
         If ReturnThis = 2 Then
            Return 1
         EndIf
         'neither or both folders
         ReturnThis = SortUDNE(Str1,Str2,SortUp)
         Return ReturnThis
      Case 1
         'sort by type
         DebugMe "sort by type"
         If Str1 = Str2 Then
            'need to check file names
            DebugMe "both are "+Str1+" so sending filenames"
            Str1 = LCase(LVGetValue(L,I1,0))
            Str2 = LCase(LVGetValue(L,I2,0))
            ReturnThis = SortUDNE(Str1,Str2,SortUp)
            Return ReturnThis
         Else
            If Str1 = "dir" Or Str2 = "dir" Then
               'one is folder
               'keep folders on top!
               If Str1 = "dir" Then
                  Return -1
               Else
                  Return 1
               EndIf
            Else
               'neither is a folder or same type
               ReturnThis = SortUDNE(Str1,Str2,SortUp)
               Return ReturnThis
            EndIf
         EndIf
      Case 2
         'sort by date
         ReturnThis = Sort_Dir(L,I1,I2)
         If ReturnThis = 1 Then
            'one of them is a folder
            Return -1
         EndIf
         If ReturnThis = 2 Then
            Return 1
         EndIf
         'neither or both folders
         Str1 = LCase(LVGetValue(L,I1,1))
         If Str1 <> "dir" Then
            Str1 = LVGetValue(L,I1,0)
            Str2 = LVGetValue(L,I2,0)
            V1 = FileDateTime(LookP+Str1)
            V2 = FileDateTime(LookP+Str2)
            If SortUp Then
               If V1 < V2 Then
                  Return -1
               Else
                  Return 1
               EndIf
            Else
               If V1 < V2 Then
                  Return 1
               Else
                  Return -1
               EndIf
            EndIf
         EndIf
      Case 3
         'sort by size
         ReturnThis = Sort_Dir(L,I1,I2)
         If ReturnThis = 1 Then
            'one of them is a folder
            Return -1
         EndIf
         If ReturnThis = 2 Then
            Return 1
         EndIf
         'neither or both folders
         Str1 = LCase(LVGetValue(L,I1,1))
         If Str1 <> "dir" Then
            Str1 = LVGetValue(L,I1,0)
            Str2 = LVGetValue(L,I2,0)
            V1 = FileLen(LookP+Str1)
            V2 = FileLen(LookP+Str2)
            If SortUp Then
               If V1 < V2 Then
                  Return -1
               Else
                  Return 1
               EndIf
            Else
               If V1 < V2 Then
                  Return 1
               Else
                  Return -1
               EndIf
            EndIf
         EndIf
      Case Else
         'sort by attrib
         ReturnThis = Sort_Dir(L,I1,I2)
         If ReturnThis = 1 Then
            'one of them is a folder
            Return -1
         EndIf
         If ReturnThis = 2 Then
            Return 1
         EndIf
         'neither or both folders no sort!
   End Select
   'say they are equal...for now
   Return 0
End Function


Your compare routine is nice and simple, and thanks for the ResetLParam code.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Postby bcohio2001 » Jun 13, 2011 1:01

Version 1.1 will be out in the next couple days.

-- Changed RefreshFTPFiles() in WM_TIMER to a "harmless?" FtpGetCurrentDirectory()
-- Added on screen log of ftp events. Not scrollable
-- Added options for keeping folders grouped together, or forcing them to the top of list.
-- Sort routine for listview, I think got the logics right....Thanks Loe!!!
-- Other minor changes

************************
Working on:
-- Figure out difference in Server/local times
-- Tweeking Trash Bin

If anyone is trying this, change your WM_TIMER to this

Code: Select all

      Case WM_TIMER
         UpdateTrees
         x = 5 'set idle time
         If Connected = TRUE And LastFTP + 60 * x < Timer Then
            LogFTP "Session idle for more than "+Str(x)+" minutes."
            x = MAX_PATH
            Dim As ZString * MAX_PATH z
             'harmless???
            If FtpGetCurrentDirectory(ftp.hconn,@z,@x) = FALSE Then
               'lost connection?
               MessageBox(hWin,"Lost connection with server","",MB_OK)
               LogFTP "Lost connection with server"
               FTPClose
            Else
               DebugFile "FTP","FtpGetCurrentDirectory returned "+z
               LastFTP = Timer
            EndIf
         EndIf

The RefreshFTPFiles was undoing any "sort". Which didn't work good anyway.

Thanks Loe!!! I guess I was "over thinking".
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Postby bcohio2001 » Jul 14, 2011 0:24

A "few days" turned into a month. Was waiting to get final tweeks into my Phone Controller program and writing a "Please Wait" dialog.

Updated files at site. See first post for changes and link to source code.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Postby bcohio2001 » Aug 18, 2011 23:31

v1.2 08/18/2011
-- Added Rename to pop up menu in file lists.
-- Compare file dates and times of files in both listviews (both local or one of them ftp).
-- Option to keep log of ftp sessions.
-- Create new folder or file, and creating folder on FTP server.

************************
Working on:

Want to add:
-- Trapping events on the file listing:
---- Open/View file when user hits enter key
-- Make my own -- Open With.
-- Properties window

Unsure of:
-- FTP renaming of files, folder uploads and folder deletions. Not tested.
-- Restoring from Trash Bin of files to folders that no longer exists. Or restoring whole folders.
Mihail_B
Posts: 271
Joined: Jan 29, 2008 11:20
Location: Romania
Contact:

Postby Mihail_B » Aug 20, 2011 5:21

can you "scale" the explorer window such that a netbook user will be able to see the whole window ?
thanks (some netbooks are limited to 1024x600; can plug in an external monitor but only @ home )
-------
nice .. it works fast ... this is good when you have lot of stuff to do and you need to do it fast
looks useful
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Postby bcohio2001 » Aug 30, 2011 0:43

v1.2.1 08/29/2011
-- The main dialog and the trash bin dialog are now both resizable. Suggested by Mihail_B.
-- In trash bin dialog, moved the button options to a menu.
Fix:
-- FTP not able to change directories.

Working on:
-- Properties window - give ablitity to change more about file. Attributes, date time....

To much work to add:
-- Trapping events on the file listing: Open/View file when user hits enter key
---- Windows has it's own key trap for listviews. Would have to intercept and check for key presses.

Want to add:
-- Make my own -- Open With.

Unsure of:
-- FTP renaming of files, folder uploads and folder deletions. Not tested.
-- Restoring from Trash Bin of files to folders that no longer exists. Or restoring whole folders.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Double directory explorer

Postby bcohio2001 » Mar 19, 2012 18:43

v1.3 03/19/2012
Changed:
-- using WIN32_FIND_DATA to return more file info than general DIR()
-- Removed reference to "../WinHelper.bi"
-- Rework file compare dlg. Show paths in display.
-- Updated and clarified the Manual

Added:
-- Properties window - file(s) only. Give ablitity to change attributes, name.

Want to add:
1. Properties window - one folder selected. Give ablitity to change attributes, name.
2. Properties window - Catch all. Just general totals.
3. Make my own -- Open With.
4. Tool tip to display more file info than displayed in listview

Unsure of:
-- FTP renaming of files, folder uploads and folder deletions. Not tested.
-- Restoring from Trash Bin of files to folders that no longer exists. Or restoring whole folders.
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Double directory explorer

Postby bcohio2001 » Jan 12, 2013 23:36

** Note: As of August 2012 (after v1.3), no longer have access to FTP server for testing. **

v1.4a 01/12/2013
Fixes:
-- Display in listviews when there are no files in folder.
-- FTP idle past midnight.
-- Temporarily removed Please Wait notification.
---- General file handling will start one, then folder handling would start another causing a "clash".
-- Disable "timer" before file copying and moving.
-- Listview sorts.
-- Better checking in renaming of files.

Add:
-- Zip file handling, in top view only. (Reason for "beta tests")
---- Temporarily extract and view files in zip.
---- Add and move to EXISTING zip file.
---- Remove from zip file.
---- Upload from zip to FTP server.
---- Download from FTP server to EXISTING zip file.
---- Rename entry.
---- Create new folder.
---- Sort listview according to column click.
-- Show icons of files in listviews.
-- Regular listviews with small or large icons.
-- Properties window - one folder selected. Give ablitity to change attributes, name.
-- Properties window - Catch all. Just general totals.

Want to add:
-- More zip functionallity.
---- create new zip file.
---- properties for file(s) in zip. (via right click)
---- work with encrypted zip files.
---- zip file handling in bottom view.
---- zip to zip file transfer.
-- Make my own -- Open With.
-- Tool tip to display more file info than displayed in listview

Unsure of:
-- FTP renaming of files, folder uploads and folder deletions. Never tested.
-- Restoring from Trash Bin of files to folders that no longer exists. Or restoring whole folders.
Kot
Posts: 336
Joined: Dec 28, 2006 10:34

Re: Double directory explorer

Postby Kot » Jan 15, 2013 12:32

Looks nice, but I got used to some icons. And when startin it displays an error message "Find associated program" "Can not find file C:\pagefile.sys"
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Double directory explorer

Postby bcohio2001 » Jan 17, 2013 2:04

Kot wrote:Looks nice, but I got used to some icons. And when startin it displays an error message "Find associated program" "Can not find file C:\pagefile.sys"

Thanks for the notice.
"C:\pagefile.sys" is one of those OS created files. And ONLY used by the OS, so it is not "really" a file.
So just ignore this error, will "hack" it out next release.
You can navigate off the root of C: drive, both top and bottom, and select "Save current as default" in menu.

As for the icons, still trying to figure out better ways to find what icons to use.

(Edit)
In file "LV_Control.bi".
Just after the "While", need to add these lines in the two subs "GetFileListTop" and "GetFileListBottom".

Code: Select all

         'OS file hack
         If LCase(RetStat.FName) = "pagefile.sys" Then RetStat.FName = "."
         If LCase(RetStat.FName) = "hiberfil.sys" Then RetStat.FName = "."
bcohio2001
Posts: 556
Joined: Mar 10, 2007 15:44
Location: Ohio, USA
Contact:

Re: Double directory explorer

Postby bcohio2001 » Jan 17, 2013 17:48

Just noticed that moving to a zip file does not work correctly. Loss of data will occur!
marpon
Posts: 342
Joined: Dec 28, 2012 13:31
Location: Paris - France

Re: Double directory explorer

Postby marpon » Jan 23, 2013 12:42

here it is a very good tool done in purebasic

http://www.lsi-dev.com/index.php?mod=download&ac=afficherid&id=58

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 7 guests