Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing Folder View in ActiveX WebBrowser in Dlg
#1
Hi All,
Does anyone know how to change folder view in a WebBrowser window I have in a dialog. Currently, I am using that window to show either pdf's or folder views. When the item to be displayed is a folder with many items, the default icon view is undesirable because the filenames are too long. The "Details" folder view would work but I don't know how to send that message. I looked here but don't quite understand it:

http://msdn.microsoft.com/en-us/library/...S.85).aspx

This is some sample code:

Function dlg_SampleFolder
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


str controls = "23"
str ax23SHD = "http://www.quickmacros.com/forum"
if(!ShowDialog("dlg_SampleFolder" &dlg_SampleFolder &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 511 682 "Doc Browser"
;16 Button 0x54032000 0x0 8 16 232 32 "Browse Folder1"
;1 Button 0x54030001 0x0 1312 10 12 14 "OK"
;23 ActiveX 0x54030000 0x0 8 52 498 621 "SHDocVw.WebBrowser"
;17 Button 0x54032000 0x0 246 16 70 32 "Open Pdf1"
;3 Button 0x54032000 0x0 320 16 62 32 "Open Url1"
;6 Button 0x54032000 0x0 384 16 68 32 "Open WordDoc1"
;5 Button 0x54032000 0x0 454 16 54 32 "Open ExcelDoc1"
;END DIALOG
;DIALOG EDITOR: "" 0x2030208 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY    
,case WM_SETCURSOR
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 16
,,_s = "C:\Folder1"
,,_s.setwintext(id(23 hDlg))
,case 4
,,_s = "C:\Folder1\WordDoc1.doc"
,,_s.setwintext(id(23 hDlg))
,case 5
,,_s = "C:\Folder1\ExcelDoc1.xls"
,,_s.setwintext(id(23 hDlg))
,case 3
,,_s = "http://www.google.com"
,,_s.setwintext(id(23 hDlg))
ret 1

Thanks for any thoughts!
Stuart
#2
Function dlg_folder_view
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4"
str ax3SHD cb4
ax3SHD="$personal$"
cb4="FVM_ICON[]FVM_SMALLICON[]FVM_LIST[]FVM_DETAILS[]FVM_THUMBNAIL[]FVM_TILE[]FVM_THUMBSTRIP"; if(_winver>=0x601) cb4+"[]FVM_CONTENT"
if(!ShowDialog("dlg_folder_view" &dlg_folder_view &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 437 380 "Form"
;3 ActiveX 0x54000000 0x0 0 20 438 360 "SHDocVw.WebBrowser"
;4 ComboBox 0x54230243 0x0 2 4 96 213 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030208 "" "" ""

ret
;messages
SHDocVw.WebBrowser we3
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case CBN_SELENDOK<<16|4
,_i=CB_SelectedItem(lParam)+1
,we3._getcontrol(id(3 hDlg))
,Shell32.ShellFolderView fv=we3.Document
,fv.CurrentViewMode=_i
,
,case IDOK
,case IDCANCEL
ret 1
#3
wow! amazing!!
thanks so much
Stuart
#4
Thank you for this example!

Could you please show how to return the current selected file or folder when an "OK" button is pressed?
(I looked at the events of the "SHDocVw.WebBrowser we3" and tried to add an event to it and output the selected file/folder but I couldn't do it.)
#5
Function dlg_folder_view
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4 6"
str ax3SHD cb4 e6
ax3SHD="$personal$"
cb4="FVM_ICON[]FVM_SMALLICON[]FVM_LIST[]FVM_DETAILS[]FVM_THUMBNAIL[]FVM_TILE[]FVM_THUMBSTRIP"; if(_winver>=0x601) cb4+"[]FVM_CONTENT"
if(!ShowDialog("dlg_folder_view" &dlg_folder_view &controls)) ret
out e6

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 441 374 "Form"
;3 ActiveX 0x54000000 0x0 0 20 440 352 "SHDocVw.WebBrowser"
;4 ComboBox 0x54230243 0x0 2 4 96 213 ""
;5 Button 0x54032000 0x0 116 2 64 14 "Open selected"
;6 Edit 0x44000080 0x200 236 2 96 14 ""
;7 Button 0x54032000 0x0 182 2 48 14 "Up"
;1 Button 0x54030001 0x0 338 2 48 14 "OK"
;2 Button 0x54030000 0x0 388 2 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040100 "" "" "" ""

ret
;messages
SHDocVw.WebBrowser we3
Shell32.ShellFolderView fv
Shell32.FolderItem fi
sel message
,case WM_INITDIALOG
,we3._getcontrol(id(3 hDlg))
,fv=we3.Document
,;fv.FilterView("*.txt")
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
we3._getcontrol(id(3 hDlg))
sel wParam
,case CBN_SELENDOK<<16|4
,_i=CB_SelectedItem(lParam)+1
,fv=we3.Document
,fv.CurrentViewMode=_i
,
,case 5 ;;open selected
,fv=we3.Document
,fi=fv.FocusedItem
,;out fi.Path
,if fi.IsFolder
,,we3.Navigate(fi.Path)
,else
,,fi.InvokeVerb
,
,case 7 ;;Up
,;we3.GoBack ;;error
,;we3.ExecWB ?
,_s=we3.LocationURL
,_s.getpath
,we3.Navigate(_s)
,
,case IDOK
,;get path of selected item
,fv=we3.Document
,fi=fv.FocusedItem
,str path=fi.Path
,;out path
,path.setwintext(id(6 hDlg))
,
ret 1
#6
Thank you very much!!!
#7
Sorry, a small question (I hope).

Is it possible to disable the colums (date, type,...)

I tried to find it here, but could not find it:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
And in the "ShellFolderViewOptions Flags" beneath on that page.
#8
I also cannot find.
#9
Ok that is no problem! Thank you!
#10
is it possible to get the selected file/folder if it is left clicked in the 'SHDocVw.WebBrowser'.
(not through a button, but as soon as a file or folder is left clicked in the 'SHDocVw.WebBrowser' output the selected item full path)
#11
I cannot find an "OnClick" event. This is for "SelectionChanged".
under fv=we3.Document:
Code:
Copy      Help
,fv._setevents("sub.fv")
at the very bottom:
Code:
Copy      Help
#sub fv_SelectionChanged
function Shell32.IShellFolderViewDual3'fv
Shell32.FolderItem fi=fv.FocusedItem
str path=fi.Path
out path

In need on click, can use message WM_SETCURSOR.
#12
Thank you!!!
#13
Sorry I have another 2 questions about this dialog:

1)
Is it possible, when double clicking on a folder to navigate to the contents of that folder within this dialog.
Now when I double click on a folder, it opens that folder in a windows explorer window.

2)
And what must I add in the subfunction "#sub fv_SelectionChanged" to navigate to a folder also within this dialog.
When I add this:
Code:
Copy      Help
SHDocVw.WebBrowser- we3
we3.Navigate(path)
It only works once after I press "UP", once the "UP" button is pressed it doesn't work anymore.
#14
1. Tested double-click:
On Windows 10 opens folder in the same dialog/control, not in Windows Explorer.
On Windows 7 - in Windows Explorer.
On XP - nowhere.

Try to somehow disable opening by double-clicking and instead call Navigate.

I think that these COM interfaces are unreliable, limited, almost undocumented, and perhaps deprecated. But I don't know another easy way to display a folder in a dialog.

2. It seems need to set events when current folder changed.

Function dlg_folder_view
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 441 374 "Form"
;3 ActiveX 0x54000000 0x0 0 20 440 352 "SHDocVw.WebBrowser"
;4 ComboBox 0x54230243 0x0 2 4 96 213 ""
;5 Button 0x54032000 0x0 116 2 64 14 "Open selected"
;6 Edit 0x44000080 0x200 236 2 96 14 ""
;7 Button 0x54032000 0x0 182 2 48 14 "Up"
;1 Button 0x54030001 0x0 338 2 48 14 "OK"
;2 Button 0x54030000 0x0 388 2 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040100 "" "" "" ""

str controls = "3 4 6"
str ax3SHD cb4 e6
cb4="FVM_ICON[]FVM_SMALLICON[]FVM_LIST[]FVM_DETAILS[]FVM_THUMBNAIL[]FVM_TILE[]FVM_THUMBSTRIP"; if(_winver>=0x601) cb4+"[]FVM_CONTENT"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
out e6


#sub DlgProc
function# hDlg message wParam lParam
SHDocVw.WebBrowser we3
Shell32.ShellFolderView fv
Shell32.FolderItem fi
sel message
,case WM_INITDIALOG
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3") ;;need DocumentComplete event
,
,;initial folder
,we3.Navigate(_s.expandpath("$personal$"))
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
we3._getcontrol(id(3 hDlg))
sel wParam
,case CBN_SELENDOK<<16|4
,_i=CB_SelectedItem(lParam)+1
,fv=we3.Document
,fv.CurrentViewMode=_i
,
,case 5 ;;open selected
,fv=we3.Document
,fi=fv.FocusedItem
,;out fi.Path
,if fi.IsFolder
,,we3.Navigate(fi.Path)
,else
,,fi.InvokeVerb
,
,case 7 ;;Up
,;we3.GoBack ;;error
,;we3.ExecWB ?
,_s=we3.LocationURL
,_s.getpath
,we3.Navigate(_s)
,
,case IDOK
,;get path of selected item
,fv=we3.Document
,fi=fv.FocusedItem
,str path=fi.Path
,;out path
,path.setwintext(id(6 hDlg))
,
ret 1


#sub we3_DocumentComplete
function IDispatch'pDisp `&URL SHDocVw.IWebBrowser2'we3
;out __FUNCTION__
Shell32.ShellFolderView fv=we3.Document
fv._setevents("sub.fv")


#sub fv_SelectionChanged
function Shell32.IShellFolderViewDual3'fv
Shell32.FolderItem fi=fv.FocusedItem
str path=fi.Path
out path
#15
Thank you very much for this!
#16
Sorry, another question about this

Under: case 7 UP
In the line: "we3.Navigate(_s)"
If I output _s, I get the following
Code:
Copy      Help
file:///E:/test/subfolder_1/folder_a/

Is there a QM function that can translate that to a normal windows path
Code:
Copy      Help
E:\test\subfolder_1\folder_a\

I can use simple string functions to modify it, but I was wondering if there is a QM function for this?
#17
Try PathCreateFromUrl. But maybe easier with string functions.

BTW, PathCreateFromUrl has many useful friends, PathX and UrlX functions, look in MSDN. For example UrlCreateFromPath.
#18
Thank you!!!
#19
Sorry me again...

Is there a way to know when a webpage is fully loaded within the "ax23SHD"-SHDocVw.WebBrowser control?
within the example at the top of this thread, a url is send like this:

_s.setwintext(id(23 hDlg)) => _s="www.google.com"

I also use this method. Is it possible to know when a webpage is fully loaded in that control (id = 23)?
#20
Is there a way to use: SortColumns
Below code does not work.
Code:
Copy      Help
BSTR s="Date Modified" ;; s="PKEY_ItemNameDisplay" (does not work).
fv.SortColumns=s

I tried the following links:
ShellFolderView [Events, Methods, Properties]: https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
ShellFolderView.ViewOptions property: https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

Shell Structures >> SORTCOLUMN structure: https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Code:
Copy      Help
typedef struct SORTCOLUMN {
  PROPERTYKEY   propkey;
  SORTDIRECTION direction;
} SORTCOLUMN;

For sorting by type I used, which works. That's why I was hoping I could go the same route when Sorting...:
[code]
BSTR s="Type"
fv1.GroupBy=s
Page: https://msdn.microsoft.com/en-us/library...85%29.aspx

SORTDIRECTION: SORT_DESCENDING/SORT_ASCENDING
[/code]

Property System Reference >> Structures: https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Code:
Copy      Help
typedef struct {
  GUID  fmtid;
  DWORD pid;
} PROPERTYKEY;

If this will take to much time to get it working then please skip it.

For "grouping by" I used the following which worked:
Code:
Copy      Help
BSTR s="Type"
fv.GroupBy=s
Page: https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
That's why I hoped 'Sorting' could be done with the same approach...
#21
Function dlg_folder_view
Code:
Copy      Help
,case 8 ;;Sort
,fv=we3.Document
,out fv.SortColumns ;;to get column names like below, manually sort a column and then run this. Names for descending sorting are with "-", and this code shows it.
,fv.SortColumns="prop:System.ItemTypeText;"
#22
I really appreciate this!!!
Thank you!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)