1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Added ability to set default folder

This commit is contained in:
Brian Fiete 2019-09-19 05:34:36 -07:00
parent 4e2cc8875e
commit bda5f560eb
2 changed files with 18 additions and 0 deletions

View file

@ -51,6 +51,17 @@ namespace System.IO
protected Result<DialogResult> RunDialog_New(Windows.HWnd hWndOwner, FolderBrowserDialog.COM_IFileDialog* fileDialog)
{
if (!mSelectedPath.IsEmpty)
{
COM_IShellItem* folderShellItem = null;
Windows.SHCreateItemFromParsingName(mSelectedPath.ToScopedNativeWChar!(), null, COM_IShellItem.sIID, (void**)&folderShellItem);
if (folderShellItem != null)
{
fileDialog.VT.SetDefaultFolder(fileDialog, folderShellItem);
folderShellItem.VT.Release(folderShellItem);
}
}
fileDialog.VT.SetOptions(fileDialog, .PICKFOLDERS);
fileDialog.VT.Show(fileDialog, hWndOwner);
@ -159,6 +170,8 @@ namespace System.IO
struct COM_IShellItem : Windows.COM_IUnknown
{
public static Guid sIID = .(0x43826d1e, 0xe718, 0x42ee, 0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe);
public enum SIGDN : uint32
{
NORMALDISPLAY = 0x00000000, // SHGDN_NORMAL

View file

@ -95,6 +95,8 @@ namespace System
public static extern void CoTaskMemFree(void* ptr);
}
public struct COM_IBindCtx;
public function int WndProc(HWnd hWnd, int32 msg, int wParam, int lParam);
public delegate IntBool EnumThreadWindowsCallback(HWnd hWnd, void* extraParameter);
@ -1198,6 +1200,9 @@ namespace System
[Import("shell32.lib"), CLink, StdCall]
public static extern int SHBrowseForFolder(ref BrowseInfo bi);
[Import("shell32.lib"), CLink, StdCall]
public static extern COM_IUnknown.HResult SHCreateItemFromParsingName(char16* pszPath, COM_IBindCtx *pbc, Guid riid, void **ppv);
[CLink, StdCall]
public static extern int32 GetLastError();