Use FolderRequester windows [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Use FolderRequester windows [Resolved]

Post by Kwai chang caine »

Hello at all :D

Thanks to this code of TATANAS, i can now open the real FolderRequester of windows 8)

Code: Select all

Interface IFileOpenDialog
   QueryInterface(riid,ppvObject)
   AddRef()
   Release()
   Show(hwndOwner)
   SetFileTypes(cFileTypes,rgFilterSpec)
   SetFileTypeIndex(iFileType)
   GetFileTypeIndex(piFileType)
   Advise(pfde,pdwCookie)
   Unadvise(dwCookie)
   SetOptions(fos)
   GetOptions(pfos)
   SetDefaultFolder(psi)
   SetFolder(psi)
   GetFolder(ppsi)
   GetCurrentSelection(ppsi)
   SetFileName(pszName)
   GetFileName(pszName)
   SetTitle(pszTitle)
   SetOkButtonLabel(pszText)
   SetFileNameLabel(pszLabel)
   GetResult(ppsi)
   AddPlace(psi,fdap)
   SetDefaultExtension(pszDefaultExtension)
   Close(hr)
   SetClientGuid(guid)
   ClearClientData()
   SetFilter(pFilter)
   GetResults(ppenum)
   GetSelectedItems(ppsai)
  EndInterface
  
  Define pFOD.IFileOpenDialog
  Define pSI.IShellItem
  Define buffer.i
  Define folder$
 
  CoInitialize_(#Null)
  
  If CoCreateInstance_(?CLSID_IFileOpenDialog, #Null, 1, ?IID_IFileOpenDialog, @pFOD) = #S_OK
  
   pFOD\SetOptions($40|$20)
   
   If pFOD\Show(0) = #S_OK
   
    pFOD\GetResult(@pSI)
    pSI\GetDisplayName($80058000, @buffer)
    folder$ = PeekS(buffer, -1, #PB_Unicode)
    CoTaskMemFree_(buffer)
    
   EndIf
   
   pFOD\Release()
   
  EndIf
  
  CoUninitialize_()
    
  DataSection 
   CLSID_IFileOpenDialog: 
   Data.b $9C,$5A,$1C,$DC,$8A,$E8,$DE,$4D,$A5,$A1,$60,$F8,$2A,$20,$AE,$F7
   IID_IFileOpenDialog: 
   Data.b $88,$72,$7C,$D5,$AD,$D4,$68,$47,$BE,$02,$9D,$96,$95,$32,$D9,$60
  EndDataSection 
But i have not found how i can give the default folder :oops:
I have try to change the CurrentDirectory with PB but that not works :|

Code: Select all

  OldCurrentFolder$ = GetCurrentDirectory()
  SetCurrentDirectory("C:\Windows\")
  ........
  .........
  SetCurrentDirectory(OldCurrentFolder$)
Have you a way for open the real folder requester of windows in a folder i can choose

Have a good day
Last edited by Kwai chang caine on Sun Aug 15, 2021 4:35 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
User avatar
Caronte3D
Addict
Addict
Posts: 1055
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Use FolderRequester windows

Post by Caronte3D »

In that code I see: "SetDefaultFolder(psi)" have you tried it?
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Use FolderRequester windows

Post by Kwai chang caine »

Hello Caronte

You have right, but how i can enter value in this interface ? :oops:
I have try to add

Code: Select all

  Path$ = "C:\"
    pFOD\SetDefaultFolder(@Path$) 

Code: Select all

If pFOD\Show(0) = #S_OK
    
    Path$ = "C:\"
    pFOD\SetDefaultFolder(@Path$) 
    pFOD\GetResult(@pSI)
    pSI\GetDisplayName($80058000, @buffer)
    folder$ = PeekS(buffer, -1, #PB_Unicode)
    CoTaskMemFree_(buffer)
    
   EndIf
Without succes :|
ImageThe happiness is a road...
Not a destination
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Use FolderRequester windows

Post by JHPJHP »

Hi Kwai chang caine,

Try the following:
- Windows Services & Other Stuff\Other_Stuff\CommonItemDialog\OpenFolderRequester.pb
Last edited by JHPJHP on Sat Aug 14, 2021 8:21 pm, edited 1 time in total.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Use FolderRequester windows

Post by Kwai chang caine »

Hello JHPJHP :D
Thanks a lot for your code 8)

I have try it, and apparently i have bad explained what i want :oops:
When i run your nice code like that

Code: Select all

OpenFolderRequester("Select Folder", "d:\Temp\")
The windows requester open in the "D" drive and write the word "Temp" in default texte :shock:
If i click on the "open folder" button it's good, but what i search to do, it's direcltly open in "D:\Temp\" folder before do something

Excuse me for my error :oops:
ImageThe happiness is a road...
Not a destination
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Use FolderRequester windows

Post by JHPJHP »

Hi Kwai chang caine,

Everything you need was in the code I provided. The logic you're referring to was by design, and took extra coding to achieve.

Unless I'm missing something, just REM the following block of code from the include file.

Code: Select all

;If FindString(FolderName, "\")
;  FileOpenDialog\SetFileName(@FolderName)
;Else
;  ShellItem\GetDisplayName(#SIGDN_NORMALDISPLAY, @ppszName)
;  FolderName = PeekS(ppszName)
;  CoTaskMemFree_(ppszName)
;  FileOpenDialog\SetFileName(@FolderName)
;EndIf
;ShellItem\GetParent(@ShellItem)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Use FolderRequester windows

Post by Kwai chang caine »

It's exactely that i want

Image

Thanks a lot MASTER for your precious help 8)
I wish you the best sunday of the woooooorld !!!
ImageThe happiness is a road...
Not a destination
drgolf
User
User
Posts: 90
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Re: Use FolderRequester windows [Resolved]

Post by drgolf »

Maybe too late...

Code works on pb 6 asm and c on win 10 x64.
Not tested on x86

Code: Select all

EnableExplicit
;
Prototype.i Protoparse(name.p-unicode,pbc.i,riid.i, psi.ishellitem)

Procedure.i shcreateitemfromparsingname(pszsrc_dest_item.s,pbc.i,riid.i)
  Protected psi.ishellitem, sh.protoparse
  ;
  If OpenLibrary(0,"shell32.dll")
  SH=GetFunction(0,"SHCreateItemFromParsingName")
  If sh
    ;CallFunctionFast(*sh,@pszsrc_dest_item,pbc,riid,@psi)
    SH(pszSrc_Dest_Item,pbc,riid,@psi)   
  EndIf
  CloseLibrary(0)  
 EndIf
; 
ProcedureReturn psi
If psi<>0
  psi\Release()
EndIf
;
EndProcedure

Interface IFileOpenDialog
   QueryInterface(riid,ppvObject)
   AddRef()
   Release()
   Show(hwndOwner)
   SetFileTypes(cFileTypes,rgFilterSpec)
   SetFileTypeIndex(iFileType)
   GetFileTypeIndex(piFileType)
   Advise(pfde,pdwCookie)
   Unadvise(dwCookie)
   SetOptions(fos)
   GetOptions(pfos)
   SetDefaultFolder(psi)
   SetFolder(psi)
   GetFolder(ppsi)
   GetCurrentSelection(ppsi)
   SetFileName(pszName)
   GetFileName(pszName)
   SetTitle(pszTitle)
   SetOkButtonLabel(pszText)
   SetFileNameLabel(pszLabel)
   GetResult(ppsi)
   AddPlace(psi,fdap)
   SetDefaultExtension(pszDefaultExtension)
   Close(hr)
   SetClientGuid(guid)
   ClearClientData()
   SetFilter(pFilter)
   GetResults(ppenum)
   GetSelectedItems(ppsai)
  EndInterface
  
  Define pFOD.IFileOpenDialog
  Define pSI.IShellItem
  Define buffer.i
  Define folder$
 
  CoInitialize_(#Null)
  ;  
  If CoCreateInstance_(?CLSID_IFileOpenDialog, #Null, 1, ?IID_IFileOpenDialog, @pFOD) = #S_OK
  ;
  pFOD\SetOptions($40|$20)
  
  ;FILL default folder
  psi=shcreateitemfromparsingname("c:\windows\",#Null,?iid_ishellitem) ;;;>>>>>> DEFAULT FOLDER
  pfod\SetFolder(psi)
  ; 
   If pFOD\Show(0) = #S_OK
   
    pFOD\GetResult(@pSI)
    pSI\GetDisplayName($80058000, @buffer)
    folder$ = PeekS(buffer, -1, #PB_Unicode)
    Debug folder$
    CoTaskMemFree_(buffer)
    
   EndIf
   psi\Release()
   ;
   pFOD\Release()
   
  EndIf
  
  CoUninitialize_()
    
  DataSection 
   CLSID_IFileOpenDialog: 
   Data.b $9C,$5A,$1C,$DC,$8A,$E8,$DE,$4D,$A5,$A1,$60,$F8,$2A,$20,$AE,$F7
   IID_IFileOpenDialog: 
   Data.b $88,$72,$7C,$D5,$AD,$D4,$68,$47,$BE,$02,$9D,$96,$95,$32,$D9,$60
   ;
   IID_IShellItem:
   Data.l $43826d1e
   Data.w $e718,$42ee
   Data.b $bc,$55,$a1,$e2,$61,$c3,$7b,$fe
  EndDataSection 

User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Use FolderRequester windows [Resolved]

Post by Kwai chang caine »

Hello DRGOLF :D

Yes your code works too 8)
Thanks :wink:
Maybe too late...
Effectively, JHPJHP give to me the good answer 8)
But it's always interesting, first to see another code, secondely to read another friend who want to help me, mainly when i never talk to him :wink:
This time... it's to late for me :mrgreen: to wish you a very welcome in the PB family 8)
Have a good day you too 8)
ImageThe happiness is a road...
Not a destination
Post Reply