Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SHDOC right click on folder, catch path
#1
In a SHODC control, if user right clicks on a folder and then selects "open" the shdoc control navigates to that folder location.
Is it possible to "catch" the folder location and put it in a editfield?

For example when the user right clicks "My QM" the shdoc navigates to that folder, I want to put that path in the below editfield (id: 8).
It is probably difficult request, attempted to find online: https://docs.microsoft.com/en-us/dotnet/...mework-4.8
(This might be complex, I understand if can not provide solution because time consuming)

Function shdoc_test
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CF0AC8 0x1 0 0 242 168 "Dialog"
;3 ActiveX 0x54000000 0x0 5 7 114 141 "SHDocVw.WebBrowser"
;8 Edit 0x54030080 0x200 5 151 224 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

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


#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam    
,case IDOK
,case IDCANCEL
ret 1
#2
refer to this post does what you want already

http://www.quickmacros.com/forum/showthr...5#pid27705


adjusted for your posted code
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CF0AC8 0x1 0 0 242 168 "Dialog"
;3 ActiveX 0x54000000 0x0 5 7 114 141 "SHDocVw.WebBrowser"
;8 Edit 0x54030080 0x200 5 151 224 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

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

#sub DlgProc
function# hDlg message wParam lParam
SHDocVw.WebBrowser we3
Shell32.ShellFolderView fv
Shell32.FolderItem fi
int- MhDlg
sel message
,case WM_INITDIALOG
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3") 
,;initial folder
,we3.Navigate(_s.expandpath("$Documents$"))    
,MhDlg=hDlg
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

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

#sub fv_SelectionChanged
function Shell32.IShellFolderViewDual3'fv
int- MhDlg
Shell32.FolderItem fi=fv.FocusedItem
str path=fi.Path
out path
path.setwintext(id(8 MhDlg))
#3
The code in that topic I was already using in my project but it doesn't work in my project when right clicking a folder.
Something is inhibiting the right click, I do not know what it is but I was assuming that the right click wasn't suppose to work.

Another "problem" is that the code triggers on folder-focus-change (which makes sense because the code is supposed to do that).
But what I want is: The below inputfield (id:8) get's the path when the user navigates to a folder (by right click and selecting "Open" or by double clicking on it). The current version of the code is on 'SelectionChanged'.

But still thank you! and my apologies, I wasn't clear enough in my first post.
I wouldn't never have found out that right click also works. I need to re-check/clean my code.

Edit, I might have found a way:
(It output's the path navigated to, by storing the path on 'selectionchanged' and only outputting it on 'documentcomplete')

Function shdoc_folderchange
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CF0AC8 0x1 0 0 242 168 "Dialog"
;3 ActiveX 0x54000000 0x0 5 7 114 141 "SHDocVw.WebBrowser"
;8 Edit 0x54030080 0x200 5 151 224 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

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

#sub DlgProc
function# hDlg message wParam lParam
SHDocVw.WebBrowser we3
Shell32.ShellFolderView fv
Shell32.FolderItem fi
int- MhDlg
sel message
,case WM_INITDIALOG
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3")
,;initial folder
,we3.Navigate(_s.expandpath("$Documents$"))
,MhDlg=hDlg
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

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


#sub fv_SelectionChanged
function Shell32.IShellFolderViewDual3'fv
int- MhDlg
Shell32.FolderItem fi=fv.FocusedItem
str- path=fi.Path
#4
Try this modified function and when you select (left click/double click) any folder/file and it will show the full path at the bottom dialog.

Function shdoc_folderchange
Code:
Copy      Help
#sub fv_SelectionChanged
function Shell32.IShellFolderViewDual3'fv
int- MhDlg
Shell32.FolderItem fi=fv.FocusedItem
str s=fi.Path
s.setwintext(id(8 MhDlg))
#5
@TeddyBear
I already had that working, the problem was to get the path only when navigating (double click or right click then "Open") and not when changing selection. The "solution" above I gave is something that works (although not perfect or best way).

I do really appreciate your (any) feedback!
Thanks!
#6
I think this is more what your after Ron
only populates the edit field when navigated to a folder(right click and open or double left click)
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90CF0AC8 0x1 0 0 242 168 "Dialog"
;3 ActiveX 0x54000000 0x0 5 7 114 141 "SHDocVw.WebBrowser"
;8 Edit 0x54030080 0x200 5 151 224 12 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

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

#sub DlgProc
function# hDlg message wParam lParam
SHDocVw.WebBrowser we3
int- MhDlg
sel message
,case WM_INITDIALOG
,we3._getcontrol(id(3 hDlg))
,we3._setevents("sub.we3") 
,;initial folder
,we3.Navigate(_s.expandpath("$Documents$"))    
,MhDlg=hDlg
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

#sub we3_TitleChange
function BSTR'Text SHDocVw.IWebBrowser2'we3
str fp s1 url=we3.LocationURL
PARSEDURLW pu
pu.cbSize=sizeof(pu)
ParseURLW(@url &pu)
s1.ansi(pu.pszSuffix)
s1.escape(8)
int- MhDlg
GetFullPath(s1 &fp)
fp.setwintext(id(8 MhDlg))
out fp
#7
Thanks!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)