Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
shdoc, sort date descending not working
#1
In the below code sorting on name works both ways (ascending and descending).
But sorting on 'date modified' doesn't, only ascending works.
Probably this is an issue that would take to much time to resolve, I understand if this issue is left 'as is'.

The code comes from a much bigger project in which I have multiple shdoc controls (that's why the subfunction 'sort', I hope it speaks for itself)

Links:

all system.prop listed, leftside under 'Core':
https://learn.microsoft.com/en-us/window...ties/props

ShellFolderView object:
https://learn.microsoft.com/en-us/window...dfrom=MSDN

SORTCOLUMN structure
https://learn.microsoft.com/en-us/window...dfrom=MSDN

ShellFolderView.ViewOptions property
https://learn.microsoft.com/en-us/window...dfrom=MSDN

Function SHDOC_sort
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 316 286 "Dialog" "4"
;3 ActiveX 0x54000000 0x0 3 4 308 238 "SHDocVw.WebBrowser"
;4 Button 0x54032000 0x0 8 246 84 36 "SORT DATE MODIFIED[]ASCENDING"
;5 Button 0x54032000 0x4 96 246 88 36 "SORT DATE MODIFIED[]DESCENDING"
;6 Button 0x54032000 0x4 204 246 50 36 "SORT NAME[]ASCENDING"
;7 Button 0x54032000 0x4 258 246 50 36 "SORT NAME[]DESCENDING"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str ax3SHD
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
SHDocVw.WebBrowser- we0
Shell32.ShellFolderView- fv0
Shell32.FolderItem- fi0
sel message
,case WM_INITDIALOG
,,we0._getcontrol(id(3 hDlg))
,,we0._setevents("sub.we0") ;;need DocumentComplete event
,,str p="c:\"
,,we0.Navigate(_s.expandpath(p))
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4
,,sub.sort(0 1) ;; ascending (date modified)
,case 5
,,sub.sort(0 1 1) ;; descending (date modified)
,case 6
,,sub.sort(0 0) ;; ascending (name)
,case 7
,,sub.sort(0 0 1) ;; descending (name)

ret 1


#sub we0_DocumentComplete
function IDispatch'pDisp `&URL SHDocVw.IWebBrowser2'we0
Shell32.ShellFolderView fv0

fv0=we0.Document
fv0.CurrentViewMode=4

str current_folder_path s1 url=we0.LocationURL
PARSEDURLW pu
pu.cbSize=sizeof(pu)
ParseURLW(@url &pu)
s1.ansi(pu.pszSuffix)
s1.escape(8)
GetFullPath(s1 &current_folder_path)


#sub fv0_SelectionChanged
function Shell32.IShellFolderViewDual3'fv0
int- d
Shell32.FolderItem fi0=fv0.FocusedItem
str path=fi0.Path




#sub sort
function int'sh int'col [int'desc]

;* sh:
;[0] = shdoc 0
;;[1] = shdoc 1
;;[2] = shdoc 2
;;...etcc
;(for testing purposes all other shdocs removed, only shdoc 0 in this example)


;* col:
;[0] prop:@System.ItemNameDisplay;"
;[1] prop:@System.DateModified;"
;[2] prop:@System.ItemTypeText;"
;[3] prop:@System.Size;"
;[4] prop:@System.DateCreated;"
;[5] prop:@System.DateAccessed;"

;* desc:
;if desc = 1 then the '-' is used in the sort string

SHDocVw.WebBrowser- we0
Shell32.ShellFolderView- fv0
Shell32.FolderItem- fi0

str cols=
;prop:@System.ItemNameDisplay;
;prop:@System.DateModified;
;prop:@System.ItemTypeText;
;prop:@System.Size;
;prop:@System.DateCreated;
;prop:@System.DateAccessed;

str getcol.getl(cols col)
if(desc=1)
,getcol.findreplace("@" "-") ;; descending
else
,getcol.findreplace("@" "") ;; ascending

if(sh=0)fv0=we0.Document;fv0.SortColumns=getcol


;; TEST:
;;if(sh=0)fv0=we0.Document;fv0.SortColumns="prop:System.DateModified" ;; ASCENDING
;;if(sh=0)fv0=we0.Document;fv0.SortColumns="prop:-System.DateModified" ;; DESCENDING
#2
it wasn't even sorting ascending was descending for both i checked output
this will work,  dont know why but it works for ascending
Code:
Copy      Help
if(desc=1)
,getcol.findreplace("@" "-") ;; descending
else
,getcol.findreplace("@" "+") ;; ascending
#3
Thank you!!!

EDIT:
Maybe it has something to do with:SORT_DESCENDING and SORT_ASCENDING:
https://learn.microsoft.com/en-us/window...dfrom=MSDN

In the following topic (autohotkey) I saw '1' and '-1' used for sorting ascending and descending:
https://www.autohotkey.com/boards/viewtopic.php?t=37988

So maybe the - is parsed as -1/ SORT_DESCENDING   and + as 1/SORT_ASCENDING

I don't know... probably I am wrong... anyway good find of you, thanks again!


Forum Jump:


Users browsing this thread: 1 Guest(s)