diff --git a/Files.sln b/Files.sln
index 9ee97dfae037..e6ffde265833 100644
--- a/Files.sln
+++ b/Files.sln
@@ -27,6 +27,10 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Files.App", "src\Files.App\Files.App.csproj", "{6F431D82-A5FF-4833-B5E4-702E1E523126}"
ProjectSection(ProjectDependencies) = postProject
{1EE996D6-885E-4403-A461-26C7A4E14D26} = {1EE996D6-885E-4403-A461-26C7A4E14D26}
+ {A2FF3F3B-8EBC-4108-B99D-1476B7876656} = {A2FF3F3B-8EBC-4108-B99D-1476B7876656}
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6} = {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225} = {7756A1A4-17B5-4E6B-9B12-F19AA868A225}
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125} = {B3FE3F3B-CECC-4918-B72B-5488C3774125}
EndProjectSection
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "Files.Package", "src\Files.App (Package)\Files.Package.wapproj", "{8F60FD8E-1921-47D6-97B0-D26D7B3A4999}"
@@ -35,6 +39,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Files.Core.SourceGenerator"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Files.App.Server", "src\Files.App.Server\Files.App.Server.csproj", "{1EE996D6-885E-4403-A461-26C7A4E14D26}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Files.App.SaveDialog", "src\Files.App.SaveDialog\Files.App.SaveDialog.vcxproj", "{EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Files.App.SaveDialog.Win32", "src\Files.App.SaveDialog\Files.App.SaveDialog.Win32.vcxproj", "{7756A1A4-17B5-4E6B-9B12-F19AA868A225}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Files.App.OpenDialog.Win32", "src\Files.App.OpenDialog\Files.App.OpenDialog.Win32.vcxproj", "{B3FE3F3B-CECC-4918-B72B-5488C3774125}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|arm64 = Debug|arm64
@@ -411,6 +421,86 @@ Global
{1EE996D6-885E-4403-A461-26C7A4E14D26}.Store|x64.Build.0 = Store|x64
{1EE996D6-885E-4403-A461-26C7A4E14D26}.Store|x86.ActiveCfg = Store|x86
{1EE996D6-885E-4403-A461-26C7A4E14D26}.Store|x86.Build.0 = Store|x86
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Debug|arm64.ActiveCfg = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Debug|arm64.Build.0 = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Debug|x64.ActiveCfg = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Debug|x64.Build.0 = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Debug|x86.ActiveCfg = Debug|Win32
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Debug|x86.Build.0 = Debug|Win32
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Preview|arm64.ActiveCfg = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Preview|arm64.Build.0 = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Preview|x64.ActiveCfg = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Preview|x64.Build.0 = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Preview|x86.ActiveCfg = Debug|Win32
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Preview|x86.Build.0 = Debug|Win32
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Release|arm64.ActiveCfg = Release|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Release|arm64.Build.0 = Release|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Release|x64.ActiveCfg = Release|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Release|x64.Build.0 = Release|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Release|x86.ActiveCfg = Release|Win32
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Release|x86.Build.0 = Release|Win32
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Stable|arm64.ActiveCfg = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Stable|arm64.Build.0 = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Stable|x64.ActiveCfg = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Stable|x64.Build.0 = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Stable|x86.ActiveCfg = Debug|Win32
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Stable|x86.Build.0 = Debug|Win32
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Store|arm64.ActiveCfg = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Store|arm64.Build.0 = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Store|x64.ActiveCfg = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Store|x64.Build.0 = Debug|x64
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Store|x86.ActiveCfg = Debug|Win32
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}.Store|x86.Build.0 = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Debug|arm64.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Debug|arm64.Build.0 = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Debug|x64.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Debug|x64.Build.0 = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|arm64.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|arm64.Build.0 = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|x64.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|x64.Build.0 = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|arm64.ActiveCfg = Release|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|arm64.Build.0 = Release|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|x64.ActiveCfg = Release|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|x64.Build.0 = Release|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|arm64.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|arm64.Build.0 = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|x64.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|x64.Build.0 = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|arm64.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|arm64.Build.0 = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|x64.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|x64.Build.0 = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Store|x86.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Debug|x86.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Preview|x86.ActiveCfg = Debug|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Release|x86.ActiveCfg = Release|Win32
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}.Stable|x86.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|arm64.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|arm64.Build.0 = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|x64.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|x64.Build.0 = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|arm64.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|arm64.Build.0 = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|x64.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|x64.Build.0 = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|arm64.ActiveCfg = Release|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|arm64.Build.0 = Release|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|x64.ActiveCfg = Release|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|x64.Build.0 = Release|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|arm64.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|arm64.Build.0 = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|x64.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|x64.Build.0 = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|arm64.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|arm64.Build.0 = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|x64.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|x64.Build.0 = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Store|x86.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Debug|x86.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Preview|x86.ActiveCfg = Debug|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Release|x86.ActiveCfg = Release|Win32
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}.Stable|x86.ActiveCfg = Debug|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -429,6 +519,9 @@ Global
{8F60FD8E-1921-47D6-97B0-D26D7B3A4999} = {A188C26B-E731-4E0B-9D17-D21CEBD9B43F}
{6FA07816-DE0A-4D49-84E8-38E953A33C87} = {9F36C2AD-005D-4EA5-A1F1-6BC42773FC85}
{1EE996D6-885E-4403-A461-26C7A4E14D26} = {A188C26B-E731-4E0B-9D17-D21CEBD9B43F}
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6} = {A188C26B-E731-4E0B-9D17-D21CEBD9B43F}
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225} = {A188C26B-E731-4E0B-9D17-D21CEBD9B43F}
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125} = {A188C26B-E731-4E0B-9D17-D21CEBD9B43F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0E62043C-A7A1-4982-9EC9-4CDB2939B776}
diff --git a/src/Files.App.OpenDialog/Files.App.OpenDialog.Win32.vcxproj b/src/Files.App.OpenDialog/Files.App.OpenDialog.Win32.vcxproj
new file mode 100644
index 000000000000..ee88f5b2972c
--- /dev/null
+++ b/src/Files.App.OpenDialog/Files.App.OpenDialog.Win32.vcxproj
@@ -0,0 +1,475 @@
+
+
+
+
+
+
+ Debug
+ arm64
+
+
+ Debug
+ Win32
+
+
+ Preview
+ arm64
+
+
+ Preview
+ Win32
+
+
+ Preview
+ x64
+
+
+ Release
+ arm64
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+ Sideload
+ arm64
+
+
+ Sideload
+ Win32
+
+
+ Sideload
+ x64
+
+
+ Stable
+ arm64
+
+
+ Stable
+ Win32
+
+
+ Stable
+ x64
+
+
+ Store
+ arm64
+
+
+ Store
+ Win32
+
+
+ Store
+ x64
+
+
+
+
+ 16.0
+ {B3FE3F3B-CECC-4918-B72B-5488C3774125}
+ AtlProj
+ 10.0
+ DynamicLibrary
+ true
+ v143
+ Unicode
+
+
+
+
+
+
+
+ true
+ true
+ ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\
+ ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\
+ Files.App.OpenDialog$(PlatformArchitecture)
+
+
+
+ true
+ false
+ false
+ ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\
+ ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\
+ Files.App.OpenDialog$(PlatformArchitecture)
+
+
+
+
+ Use
+ Level3
+ pch.h
+ true
+
+
+ false
+ CustomOpenDialog_i.h
+ CustomOpenDialog_i.c
+ CustomOpenDialog_p.c
+ true
+ $(IntDir)CustomOpenDialog.tlb
+ true
+
+
+ 0x0410
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+ Windows
+ .\CustomOpenDialog.def
+ false
+ true
+ $(OutDir)Files.App.OpenDialog$(PlatformArchitecture)$(TargetExt)
+
+
+ xcopy /s /y "$(ProjectDir)$(OutDir)*.dll" "$(ProjectDir)..\..\src\Files.App\Assets\FilesOpenDialog"
+
+
+
+
+
+ Disabled
+ WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+ Disabled
+ _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+ Disabled
+ _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+ false
+
+
+
+
+ Create
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Files.App.OpenDialog/FilesOpenDialog.cpp b/src/Files.App.OpenDialog/FilesOpenDialog.cpp
index 5f6c79993f47..23bb55567fa7 100644
--- a/src/Files.App.OpenDialog/FilesOpenDialog.cpp
+++ b/src/Files.App.OpenDialog/FilesOpenDialog.cpp
@@ -22,16 +22,13 @@ using std::endl;
CComPtr GetSystemDialog()
{
HINSTANCE lib = CoLoadLibrary(L"C:\\Windows\\System32\\comdlg32.dll", false);
-
- BOOL(WINAPI *dllGetClassObject)(REFCLSID, REFIID, LPVOID*) = (BOOL(WINAPI*)(REFCLSID, REFIID, LPVOID*))GetProcAddress(lib, "DllGetClassObject");
-
+ BOOL(WINAPI* dllGetClassObject)(REFCLSID, REFIID, LPVOID*) =
+ (BOOL(WINAPI*)(REFCLSID, REFIID, LPVOID*))GetProcAddress(lib, "DllGetClassObject");
CComPtr pClassFactory;
dllGetClassObject(CLSID_FileOpenDialog, IID_IClassFactory, (void**)&pClassFactory);
-
CComPtr systemDialog;
pClassFactory->CreateInstance(NULL, IID_IFileOpenDialog, (void**)&systemDialog);
//CoFreeLibrary(lib);
-
return systemDialog;
}
@@ -124,6 +121,8 @@ STDAPICALL CFilesOpenDialog::Show(HWND hwndOwner)
ShExecInfo.lpFile = L"files.exe";
PWSTR pszPath = NULL;
+ HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG"));
+
if (_initFolder && SUCCEEDED(_initFolder->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath)))
{
TCHAR args[1024];
@@ -132,17 +131,40 @@ STDAPICALL CFilesOpenDialog::Show(HWND hwndOwner)
ShExecInfo.lpParameters = args;
CoTaskMemFree(pszPath);
}
-
ShExecInfo.nShow = SW_SHOW;
ShellExecuteEx(&ShExecInfo);
- if (ShExecInfo.hProcess)
+
+ if (hwndOwner)
+ EnableWindow(hwndOwner, FALSE);
+
+ MSG msg;
+ while (ShExecInfo.hProcess)
{
- WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
- CloseHandle(ShExecInfo.hProcess);
+ switch (MsgWaitForMultipleObjectsEx(1, &closeEvent, INFINITE, QS_ALLINPUT, 0))
+ {
+ case WAIT_OBJECT_0:
+ CloseHandle(ShExecInfo.hProcess);
+ ShExecInfo.hProcess = NULL;
+ break;
+ case WAIT_OBJECT_0 + 1:
+ while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ continue;
+ default: __debugbreak();
+ }
}
+ if (closeEvent)
+ CloseHandle(closeEvent);
+
if (hwndOwner)
+ {
+ EnableWindow(hwndOwner, TRUE);
SetForegroundWindow(hwndOwner);
+ }
std::ifstream file(_outputPath);
if (file.good())
@@ -203,7 +225,7 @@ STDAPICALL CFilesOpenDialog::Advise(IFileDialogEvents* pfde, DWORD* pdwCookie)
return _systemDialog->Advise(pfde, pdwCookie);
#endif
_dialogEvents = pfde;
- * pdwCookie = 0;
+ *pdwCookie = 0;
return S_OK;
}
diff --git a/src/Files.App.OpenDialog/FilesOpenDialog.h b/src/Files.App.OpenDialog/FilesOpenDialog.h
index 2934e70ccf56..52843c7e6f2d 100644
--- a/src/Files.App.OpenDialog/FilesOpenDialog.h
+++ b/src/Files.App.OpenDialog/FilesOpenDialog.h
@@ -6,7 +6,7 @@
#pragma once
-//#define DEBUGLOG
+#define DEBUGLOG
#include
#include
diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.cpp b/src/Files.App.SaveDialog/CustomSaveDialog.cpp
new file mode 100644
index 000000000000..2f9ccaf5f861
--- /dev/null
+++ b/src/Files.App.SaveDialog/CustomSaveDialog.cpp
@@ -0,0 +1,74 @@
+// CustomSaveDialog.cpp: implementazione delle esportazioni DLL.
+
+
+#include "pch.h"
+#include "framework.h"
+#include "resource.h"
+#include "CustomSaveDialog_i.h"
+#include "dllmain.h"
+
+
+using namespace ATL;
+
+// Utilizzato per determinare se la DLL può essere scaricata da OLE.
+_Use_decl_annotations_
+STDAPI DllCanUnloadNow(void)
+{
+ return _AtlModule.DllCanUnloadNow();
+}
+
+// Restituisce una class factory per creare un oggetto del tipo richiesto.
+_Use_decl_annotations_
+STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv)
+{
+ return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
+}
+
+// DllRegisterServer: aggiunge voci al Registro di sistema.
+_Use_decl_annotations_
+STDAPI DllRegisterServer(void)
+{
+ // registra gli oggetti, le librerie dei tipi e tutte le interfacce della libreria dei tipi
+ HRESULT hr = _AtlModule.DllRegisterServer();
+ return hr;
+}
+
+// DllUnregisterServer: rimuove voci dal Registro di sistema.
+_Use_decl_annotations_
+STDAPI DllUnregisterServer(void)
+{
+ HRESULT hr = _AtlModule.DllUnregisterServer();
+ return hr;
+}
+
+// DllInstall: aggiunge/rimuove voci nel Registro di sistema per ogni utente di ciascun computer.
+STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine)
+{
+ HRESULT hr = E_FAIL;
+ static const wchar_t szUserSwitch[] = L"user";
+
+ if (pszCmdLine != nullptr)
+ {
+ if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
+ {
+ ATL::AtlSetPerUserRegistration(true);
+ }
+ }
+
+ if (bInstall)
+ {
+ hr = DllRegisterServer();
+ if (FAILED(hr))
+ {
+ DllUnregisterServer();
+ }
+ }
+ else
+ {
+ hr = DllUnregisterServer();
+ }
+
+ return hr;
+}
+
+
diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.def b/src/Files.App.SaveDialog/CustomSaveDialog.def
new file mode 100644
index 000000000000..127dec0267e2
--- /dev/null
+++ b/src/Files.App.SaveDialog/CustomSaveDialog.def
@@ -0,0 +1,10 @@
+; CustomSaveDialog.def: dichiara i parametri del modulo.
+
+LIBRARY
+
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
+ DllInstall PRIVATE
diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.idl b/src/Files.App.SaveDialog/CustomSaveDialog.idl
new file mode 100644
index 000000000000..d2b45059fdfa
--- /dev/null
+++ b/src/Files.App.SaveDialog/CustomSaveDialog.idl
@@ -0,0 +1,32 @@
+// CustomSaveDialog.idl: origine IDL per CustomSaveDialog
+//
+
+// Questo file verrà elaborato dallo strumento MIDL per
+// produce la libreria dei tipi (CustomSaveDialog.tlb) e il codice di marshalling.
+
+import "oaidl.idl";
+import "ocidl.idl";
+
+[
+ uuid(21533617-c1cd-4d33-a190-21fb069b55f4),
+ version(1.0),
+]
+library CustomSaveDialogLib
+{
+ importlib("stdole2.tlb");
+ [
+ uuid(C0B4E2F3-BA21-4773-8DBA-335EC946EB8B)
+ ]
+ coclass FilesSaveDialog
+ {
+ [default] interface IFileSaveDialog;
+ interface IFileDialog;
+ interface IFileDialogCustomize;
+ interface IFileDialog2;
+ interface IObjectWithSite;
+ //interface IFileDialogPrivate;
+ interface IOleWindow;
+ };
+};
+
+import "shobjidl.idl";
diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.rc b/src/Files.App.SaveDialog/CustomSaveDialog.rc
new file mode 100644
index 000000000000..deda272e17a1
Binary files /dev/null and b/src/Files.App.SaveDialog/CustomSaveDialog.rc differ
diff --git a/src/Files.App.SaveDialog/CustomSaveDialog.rgs b/src/Files.App.SaveDialog/CustomSaveDialog.rgs
new file mode 100644
index 000000000000..e7d37400e19a
--- /dev/null
+++ b/src/Files.App.SaveDialog/CustomSaveDialog.rgs
@@ -0,0 +1,3 @@
+HKCR
+{
+}
diff --git a/src/Files.App.SaveDialog/CustomSaveDialogps.def b/src/Files.App.SaveDialog/CustomSaveDialogps.def
new file mode 100644
index 000000000000..2a4265afa9fb
--- /dev/null
+++ b/src/Files.App.SaveDialog/CustomSaveDialogps.def
@@ -0,0 +1,8 @@
+
+LIBRARY
+
+EXPORTS
+ DllGetClassObject PRIVATE
+ DllCanUnloadNow PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
diff --git a/src/Files.App.SaveDialog/Files.App.SaveDialog.Win32.vcxproj b/src/Files.App.SaveDialog/Files.App.SaveDialog.Win32.vcxproj
new file mode 100644
index 000000000000..81db2ee5f38c
--- /dev/null
+++ b/src/Files.App.SaveDialog/Files.App.SaveDialog.Win32.vcxproj
@@ -0,0 +1,475 @@
+
+
+
+
+ Debug
+ arm64
+
+
+ Debug
+ Win32
+
+
+ Preview
+ arm64
+
+
+ Preview
+ Win32
+
+
+ Preview
+ x64
+
+
+ Release
+ arm64
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+ Sideload
+ arm64
+
+
+ Sideload
+ Win32
+
+
+ Sideload
+ x64
+
+
+ Stable
+ arm64
+
+
+ Stable
+ Win32
+
+
+ Stable
+ x64
+
+
+ Store
+ arm64
+
+
+ Store
+ Win32
+
+
+ Store
+ x64
+
+
+
+
+ 16.0
+ {7756A1A4-17B5-4E6B-9B12-F19AA868A225}
+ AtlProj
+ 10.0
+ DynamicLibrary
+ true
+ v143
+ Unicode
+
+
+
+
+
+
+
+ true
+ true
+ ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\
+ ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\
+ Files.App.SaveDialog$(PlatformArchitecture)
+
+
+
+ true
+ false
+ false
+ ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\
+ ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\
+ Files.App.SaveDialog$(PlatformArchitecture)
+
+
+
+
+ Use
+ Level3
+ pch.h
+ true
+
+
+ false
+ CustomSaveDialog_i.h
+ CustomSaveDialog_i.c
+ CustomSaveDialog_p.c
+ true
+ $(IntDir)CustomSaveDialog.tlb
+ true
+
+
+ 0x0410
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+ Windows
+ .\CustomSaveDialog.def
+ false
+ true
+ $(OutDir)Files.App.SaveDialog$(PlatformArchitecture)$(TargetExt)
+
+
+ xcopy /s /y "$(ProjectDir)$(OutDir)*.dll" "$(ProjectDir)..\..\src\Files.App\Assets\FilesOpenDialog"
+
+
+
+
+
+ Disabled
+ WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+ Disabled
+ _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+ Disabled
+ _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+ false
+
+
+
+
+
+ Create
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj b/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj
new file mode 100644
index 000000000000..9e0232aa2b88
--- /dev/null
+++ b/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj
@@ -0,0 +1,475 @@
+
+
+
+
+ Debug
+ arm64
+
+
+ Debug
+ Win32
+
+
+ Preview
+ arm64
+
+
+ Preview
+ Win32
+
+
+ Preview
+ x64
+
+
+ Release
+ arm64
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+ Sideload
+ arm64
+
+
+ Sideload
+ Win32
+
+
+ Sideload
+ x64
+
+
+ Stable
+ arm64
+
+
+ Stable
+ Win32
+
+
+ Stable
+ x64
+
+
+ Store
+ arm64
+
+
+ Store
+ Win32
+
+
+ Store
+ x64
+
+
+
+
+ 16.0
+ {EBFA367F-CBDB-4CD0-B838-D6B95F61D1F6}
+ AtlProj
+ 10.0
+ DynamicLibrary
+ true
+ v143
+ Unicode
+
+
+
+
+
+
+
+ true
+ true
+ ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\
+ ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\
+ Files.App.SaveDialog$(PlatformArchitecture)
+
+
+
+ true
+ false
+ false
+ ..\..\artifacts\$(Configuration)\$(Platform)\$(MSBuildProjectName)\
+ ..\..\artifacts\intermediates\$(Platform)\$(MSBuildProjectName)\
+ Files.App.SaveDialog$(PlatformArchitecture)
+
+
+
+
+ Use
+ Level3
+ pch.h
+ true
+
+
+ false
+ CustomSaveDialog_i.h
+ CustomSaveDialog_i.c
+ CustomSaveDialog_p.c
+ true
+ $(IntDir)CustomSaveDialog.tlb
+ true
+
+
+ 0x0410
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+ Windows
+ .\CustomSaveDialog.def
+ false
+ true
+ $(OutDir)Files.App.SaveDialog$(PlatformArchitecture)$(TargetExt)
+
+
+ xcopy /s /y "$(ProjectDir)$(OutDir)*.dll" "$(ProjectDir)..\..\src\Files.App\Assets\FilesOpenDialog"
+
+
+
+
+
+ Disabled
+ WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+ Disabled
+ _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+ Disabled
+ _WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Win32
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+ MaxSpeed
+ _WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+ false
+
+
+
+
+
+ Create
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj.filters b/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj.filters
new file mode 100644
index 000000000000..a3c5c5a147aa
--- /dev/null
+++ b/src/Files.App.SaveDialog/Files.App.SaveDialog.vcxproj.filters
@@ -0,0 +1,91 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+ {487d0712-ae0c-468f-9ef2-12da6ffc5361}
+ False
+
+
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File generati
+
+
+ File di intestazione
+
+
+
+
+ File di origine
+
+
+ File di origine
+
+
+ File di origine
+
+
+ File di origine
+
+
+ File generati
+
+
+ File di origine
+
+
+
+
+ File di risorse
+
+
+
+
+ File di risorse
+
+
+ File di origine
+
+
+ File di risorse
+
+
+
+
+ File di origine
+
+
+
\ No newline at end of file
diff --git a/src/Files.App.SaveDialog/FilesDialogEvents.cpp b/src/Files.App.SaveDialog/FilesDialogEvents.cpp
new file mode 100644
index 000000000000..527c45efe244
--- /dev/null
+++ b/src/Files.App.SaveDialog/FilesDialogEvents.cpp
@@ -0,0 +1,84 @@
+#include "pch.h"
+#include "FilesDialogEvents.h"
+#include
+
+using std::cout;
+using std::wcout;
+using std::endl;
+
+FilesDialogEvents::FilesDialogEvents(IFileDialogEvents* evt, IFileDialog* cust)
+{
+ _evt = evt;
+ _cust = cust;
+}
+
+HRESULT __stdcall FilesDialogEvents::QueryInterface(REFIID riid, void** ppvObject)
+{
+ HRESULT res = _evt->QueryInterface(riid, ppvObject);
+ OLECHAR* guidString;
+ (void)StringFromCLSID(riid, &guidString);
+ std::wcout << L"Event: QueryInterface: " << guidString << L" = " << res << std::endl;
+ ::CoTaskMemFree(guidString);
+ return res;
+}
+
+ULONG __stdcall FilesDialogEvents::AddRef(void)
+{
+ cout << "Event: AddRef" << endl;
+ return _evt->AddRef();
+}
+
+ULONG __stdcall FilesDialogEvents::Release(void)
+{
+ cout << "Event: Release" << endl;
+ return _evt->Release();
+}
+
+HRESULT __stdcall FilesDialogEvents::OnFileOk(IFileDialog* pfd)
+{
+ cout << "Event: PRE OnFileOk" << endl;
+ HRESULT res = _evt->OnFileOk(_cust);
+ cout << "Event: OnFileOk = " << res << endl;
+ return res;
+}
+
+HRESULT __stdcall FilesDialogEvents::OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder)
+{
+ HRESULT res = _evt->OnFolderChanging(_cust, psiFolder);
+ cout << "Event: OnFolderChanging = " << res << endl;
+ return res;
+}
+
+HRESULT __stdcall FilesDialogEvents::OnFolderChange(IFileDialog* pfd)
+{
+ HRESULT res = _evt->OnFolderChange(_cust);
+ cout << "Event: OnFolderChange = " << res << endl;
+ return res;
+}
+
+HRESULT __stdcall FilesDialogEvents::OnSelectionChange(IFileDialog* pfd)
+{
+ HRESULT res = _evt->OnSelectionChange(_cust);
+ cout << "Event: OnSelectionChange = " << res << endl;
+ return res;
+}
+
+HRESULT __stdcall FilesDialogEvents::OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse)
+{
+ cout << "Event: OnShareViolation" << endl;
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall FilesDialogEvents::OnTypeChange(IFileDialog* pfd)
+{
+ HRESULT res = _evt->OnTypeChange(_cust);
+ cout << "Event: OnTypeChange = " << res << endl;
+ return res;
+}
+
+HRESULT __stdcall FilesDialogEvents::OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse)
+{
+ HRESULT res = _evt->OnOverwrite(_cust, psi, pResponse);
+ cout << "Event: OnOverwrite = " << res << ", " << *pResponse << endl;
+ return res;
+}
diff --git a/src/Files.App.SaveDialog/FilesDialogEvents.h b/src/Files.App.SaveDialog/FilesDialogEvents.h
new file mode 100644
index 000000000000..26a4a72208ef
--- /dev/null
+++ b/src/Files.App.SaveDialog/FilesDialogEvents.h
@@ -0,0 +1,27 @@
+#pragma once
+#include "resource.h" // simboli principali
+
+#include "oaidl.h"
+#include "ocidl.h"
+#include "shobjidl.h"
+
+class FilesDialogEvents : public IFileDialogEvents
+{
+ IFileDialogEvents* _evt;
+ IFileDialog* _cust;
+
+public:
+ FilesDialogEvents(IFileDialogEvents* evt, IFileDialog *cust);
+
+ // Ereditato tramite IFileDialogEvents
+ HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override;
+ ULONG __stdcall AddRef(void) override;
+ ULONG __stdcall Release(void) override;
+ HRESULT __stdcall OnFileOk(IFileDialog* pfd) override;
+ HRESULT __stdcall OnFolderChanging(IFileDialog* pfd, IShellItem* psiFolder) override;
+ HRESULT __stdcall OnFolderChange(IFileDialog* pfd) override;
+ HRESULT __stdcall OnSelectionChange(IFileDialog* pfd) override;
+ HRESULT __stdcall OnShareViolation(IFileDialog* pfd, IShellItem* psi, FDE_SHAREVIOLATION_RESPONSE* pResponse) override;
+ HRESULT __stdcall OnTypeChange(IFileDialog* pfd) override;
+ HRESULT __stdcall OnOverwrite(IFileDialog* pfd, IShellItem* psi, FDE_OVERWRITE_RESPONSE* pResponse) override;
+};
diff --git a/src/Files.App.SaveDialog/FilesSaveDialog.cpp b/src/Files.App.SaveDialog/FilesSaveDialog.cpp
new file mode 100644
index 000000000000..f06b5401b5a3
--- /dev/null
+++ b/src/Files.App.SaveDialog/FilesSaveDialog.cpp
@@ -0,0 +1,1106 @@
+// FilesSaveDialog.cpp: implementazione di CFilesSaveDialog
+
+#include "pch.h"
+#include "FilesDialogEvents.h"
+#include "FilesSaveDialog.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+//#define SYSTEMDIALOG
+
+using std::cout;
+using std::wcout;
+using std::endl;
+
+// CFilesSaveDialog
+
+CComPtr GetSystemDialog()
+{
+ HINSTANCE lib = CoLoadLibrary(L"C:\\Windows\\System32\\comdlg32.dll", false);
+ BOOL(WINAPI* dllGetClassObject)(REFCLSID, REFIID, LPVOID*) =
+ (BOOL(WINAPI*)(REFCLSID, REFIID, LPVOID*))GetProcAddress(lib, "DllGetClassObject");
+ CComPtr pClassFactory;
+ dllGetClassObject(CLSID_FileSaveDialog, IID_IClassFactory, (void**)&pClassFactory);
+ CComPtr systemDialog;
+ pClassFactory->CreateInstance(NULL, IID_IFileSaveDialog, (void**)&systemDialog);
+ //CoFreeLibrary(lib);
+ return systemDialog;
+}
+
+IShellItem* CloneShellItem(IShellItem* psi)
+{
+ IShellItem* item = NULL;
+ if (psi)
+ {
+ PIDLIST_ABSOLUTE pidl;
+ if (SUCCEEDED(SHGetIDListFromObject(psi, &pidl)))
+ {
+ SHCreateItemFromIDList(pidl, IID_IShellItem, (void**)&item);
+ CoTaskMemFree(pidl);
+ }
+ }
+ return item;
+}
+
+template
+CComPtr AsInterface(CComPtr dialog)
+{
+ CComPtr dialogInterface;
+ dialog->QueryInterface(&dialogInterface);
+ return dialogInterface;
+}
+
+CFilesSaveDialog::CFilesSaveDialog()
+{
+ _fos = FOS_PATHMUSTEXIST;
+ _systemDialog = nullptr;
+ _debugStream = NULL;
+ _dialogEvents = NULL;
+
+ PWSTR pszPath = NULL;
+ HRESULT hr = SHGetKnownFolderPath(FOLDERID_Desktop, 0, NULL, &pszPath);
+ if (SUCCEEDED(hr))
+ {
+ TCHAR debugPath[MAX_PATH];
+ wsprintf(debugPath, L"%s\\%s", pszPath, L"save_dialog.txt");
+#ifdef DEBUGLOG
+ _wfreopen_s(&_debugStream, debugPath, L"w", stdout);
+#endif
+ CoTaskMemFree(pszPath);
+ }
+ cout << "Create" << endl;
+
+ TCHAR tempPath[MAX_PATH];
+ GetTempPath(MAX_PATH, tempPath);
+ TCHAR tempName[MAX_PATH];
+ GetTempFileName(tempPath, L"fsd", 0, tempName);
+ _outputPath = tempName;
+
+ (void)SHGetKnownFolderItem(FOLDERID_Documents, KF_FLAG_DEFAULT_PATH, NULL, IID_IShellItem, (void**)&_initFolder);
+ hr = _initFolder->GetDisplayName(SIGDN_NORMALDISPLAY, &pszPath);
+ if (SUCCEEDED(hr))
+ {
+ wcout << L"_outputPath: " << _outputPath << L", _initFolder: " << pszPath << endl;
+ }
+
+#ifdef SYSTEMDIALOG
+ _systemDialog = GetSystemDialog();
+#endif
+}
+
+void CFilesSaveDialog::FinalRelease()
+{
+ if (_systemDialog)
+ {
+ _systemDialog.Release();
+ }
+ if (_initFolder)
+ {
+ _initFolder->Release();
+ }
+ if (_debugStream)
+ {
+ fclose(_debugStream);
+ }
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetSite(IUnknown* pUnkSite)
+{
+ cout << "SetSite" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetSite(pUnkSite);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetSite(REFIID riid, void** ppvSite)
+{
+ cout << "GetSite" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetSite(riid, ppvSite);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::EnableOpenDropDown(DWORD dwIDCtl)
+{
+ cout << "EnableOpenDropDown" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->EnableOpenDropDown(dwIDCtl);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddMenu(DWORD dwIDCtl, LPCWSTR pszLabel)
+{
+ cout << "AddMenu" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AddMenu(dwIDCtl, pszLabel);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddPushButton(DWORD dwIDCtl, LPCWSTR pszLabel)
+{
+ cout << "AddPushButton" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AddPushButton(dwIDCtl, pszLabel);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddComboBox(DWORD dwIDCtl)
+{
+ cout << "AddComboBox" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AddComboBox(dwIDCtl);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddRadioButtonList(DWORD dwIDCtl)
+{
+ cout << "AddRadioButtonList" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AddRadioButtonList(dwIDCtl);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddCheckButton(DWORD dwIDCtl, LPCWSTR pszLabel, BOOL bChecked)
+{
+ cout << "AddCheckButton" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AddCheckButton(dwIDCtl, pszLabel, bChecked);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddEditBox(DWORD dwIDCtl, LPCWSTR pszText)
+{
+ cout << "AddEditBox" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AddEditBox(dwIDCtl, pszText);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddSeparator(DWORD dwIDCtl)
+{
+ cout << "AddSeparator" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AddSeparator(dwIDCtl);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddText(DWORD dwIDCtl, LPCWSTR pszText)
+{
+ cout << "AddText" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AddText(dwIDCtl, pszText);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetControlLabel(DWORD dwIDCtl, LPCWSTR pszLabel)
+{
+ cout << "SetControlLabel" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetControlLabel(dwIDCtl, pszLabel);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetControlState(DWORD dwIDCtl, CDCONTROLSTATEF* pdwState)
+{
+ cout << "GetControlState" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetControlState(dwIDCtl, pdwState);
+#endif
+ * pdwState = CDCS_ENABLEDVISIBLE;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetControlState(DWORD dwIDCtl, CDCONTROLSTATEF dwState)
+{
+ cout << "SetControlState" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetControlState(dwIDCtl, dwState);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetEditBoxText(DWORD dwIDCtl, WCHAR** ppszText)
+{
+ cout << "GetEditBoxText" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetEditBoxText(dwIDCtl, ppszText);
+#endif
+ SHStrDupW(L"", ppszText);
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetEditBoxText(DWORD dwIDCtl, LPCWSTR pszText)
+{
+ cout << "SetEditBoxText" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetEditBoxText(dwIDCtl, pszText);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetCheckButtonState(DWORD dwIDCtl, BOOL* pbChecked)
+{
+ cout << "GetCheckButtonState" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetCheckButtonState(dwIDCtl, pbChecked);
+#endif
+ * pbChecked = false;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetCheckButtonState(DWORD dwIDCtl, BOOL bChecked)
+{
+ cout << "SetCheckButtonState" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetCheckButtonState(dwIDCtl, bChecked);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddControlItem(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel)
+{
+ cout << "AddControlItem" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AddControlItem(dwIDCtl, dwIDItem, pszLabel);
+#endif
+ _ctrlItems.push_back(dwIDItem);
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::RemoveControlItem(DWORD dwIDCtl, DWORD dwIDItem)
+{
+ cout << "RemoveControlItem" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->RemoveControlItem(dwIDCtl, dwIDItem);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::RemoveAllControlItems(DWORD dwIDCtl)
+{
+ cout << "RemoveAllControlItems" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->RemoveAllControlItems(dwIDCtl);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF* pdwState)
+{
+ cout << "GetControlItemState" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetControlItemState(dwIDCtl, dwIDItem, pdwState);
+#endif
+ * pdwState = CDCS_ENABLEDVISIBLE;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF dwState)
+{
+ cout << "SetControlItemState" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetControlItemState(dwIDCtl, dwIDItem, dwState);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetSelectedControlItem(DWORD dwIDCtl, DWORD* pdwIDItem)
+{
+ cout << "GetSelectedControlItem" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetSelectedControlItem(dwIDCtl, pdwIDItem);
+#endif
+ if (!_ctrlItems.empty()) {
+ *pdwIDItem = _ctrlItems.back();
+ return S_OK;
+ }
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetSelectedControlItem(DWORD dwIDCtl, DWORD dwIDItem)
+{
+ cout << "SetSelectedControlItem" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetSelectedControlItem(dwIDCtl, dwIDItem);
+#endif
+ _ctrlItems.push_back(dwIDItem);
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::StartVisualGroup(DWORD dwIDCtl, LPCWSTR pszLabel)
+{
+ cout << "StartVisualGroup" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->StartVisualGroup(dwIDCtl, pszLabel);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::EndVisualGroup(void)
+{
+ cout << "EndVisualGroup" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->EndVisualGroup();
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::MakeProminent(DWORD dwIDCtl)
+{
+ cout << "MakeProminent" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->MakeProminent(dwIDCtl);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetControlItemText(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel)
+{
+ cout << "SetControlItemText" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetControlItemText(dwIDCtl, dwIDItem, pszLabel);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::Show(HWND hwndOwner)
+{
+ wchar_t wnd_title[1024];
+ GetWindowText(hwndOwner, wnd_title, 1024);
+ wcout << L"Show, ID: " << GetCurrentProcessId() << endl;
+
+#ifdef SYSTEMDIALOG
+ HRESULT res = _systemDialog->Show(NULL);
+ cout << "Show, DONE: " << res << endl;
+ return res;
+#endif
+
+ SHELLEXECUTEINFO ShExecInfo = { 0 };
+ ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
+ ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
+ ShExecInfo.lpFile = L"files.exe";
+ PWSTR pszPath = NULL;
+
+ HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG"));
+
+ if (_initFolder && SUCCEEDED(_initFolder->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath)))
+ {
+ TCHAR args[1024];
+ if (!_initName.empty())
+ {
+ wsprintf(args, L"-directory \"%s\" -outputpath \"%s\" -select \"%s\"", pszPath, _outputPath.c_str(), _initName.c_str());
+ }
+ else
+ {
+ wsprintf(args, L"-directory \"%s\" -outputpath \"%s\"", pszPath, _outputPath.c_str());
+ }
+ wcout << L"Invoking: " << args << endl;
+ ShExecInfo.lpParameters = args;
+ CoTaskMemFree(pszPath);
+ }
+ ShExecInfo.nShow = SW_SHOW;
+ ShellExecuteEx(&ShExecInfo);
+
+ if (hwndOwner)
+ EnableWindow(hwndOwner, FALSE);
+
+ MSG msg;
+ while (ShExecInfo.hProcess)
+ {
+ switch (MsgWaitForMultipleObjectsEx(1, &closeEvent, INFINITE, QS_ALLINPUT, 0))
+ {
+ case WAIT_OBJECT_0:
+ CloseHandle(ShExecInfo.hProcess);
+ ShExecInfo.hProcess = NULL;
+ break;
+ case WAIT_OBJECT_0 + 1:
+ while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ continue;
+ default: __debugbreak();
+ }
+ }
+
+ if (closeEvent)
+ CloseHandle(closeEvent);
+
+ if (hwndOwner)
+ {
+ EnableWindow(hwndOwner, TRUE);
+ SetForegroundWindow(hwndOwner);
+ }
+
+ std::ifstream file(_outputPath);
+ if (file.good())
+ {
+ std::string str;
+ std::wstring_convert> converter;
+ while (std::getline(file, str))
+ {
+ std::wstring wide = converter.from_bytes(str);
+ _selectedItem = wide;
+ }
+ }
+ DeleteFile(_outputPath.c_str());
+
+ if (!_selectedItem.empty())
+ {
+ // Create destination file if not existing
+ HANDLE hFile = CreateFile(_selectedItem.c_str(), GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ CloseHandle(hFile);
+ }
+ else
+ {
+ _selectedItem = L"";
+ }
+ }
+ if (!_selectedItem.empty())
+ {
+ if (_dialogEvents)
+ {
+ _dialogEvents->OnFileOk(this);
+ }
+ }
+
+ return !_selectedItem.empty() ? S_OK : HRESULT_FROM_WIN32(ERROR_CANCELLED);
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetFileTypes(UINT cFileTypes, const COMDLG_FILTERSPEC* rgFilterSpec)
+{
+ cout << "SetFileTypes, cFileTypes: " << cFileTypes << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetFileTypes(cFileTypes, rgFilterSpec);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetFileTypeIndex(UINT iFileType)
+{
+ cout << "SetFileTypeIndex, iFileType: " << iFileType << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetFileTypeIndex(iFileType);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetFileTypeIndex(UINT* piFileType)
+{
+ cout << "GetFileTypeIndex" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->GetFileTypeIndex(piFileType);
+#endif
+ * piFileType = 1;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::Advise(IFileDialogEvents* pfde, DWORD* pdwCookie)
+{
+ cout << "Advise" << endl;
+#ifdef DEBUGLOG
+ pfde = new FilesDialogEvents(pfde, this);
+#endif
+#ifdef SYSTEMDIALOG
+ return _systemDialog->Advise(pfde, pdwCookie);
+#endif
+ _dialogEvents = pfde;
+ _dialogEvents->AddRef();
+ *pdwCookie = 4;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::Unadvise(DWORD dwCookie)
+{
+ cout << "Unadvise, dwCookie: " << dwCookie << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->Unadvise(dwCookie);
+#endif
+ _dialogEvents->Release();
+ _dialogEvents = NULL;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetOptions(FILEOPENDIALOGOPTIONS fos)
+{
+ cout << "SetOptions, fos: " << fos << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetOptions(fos);
+#endif
+ _fos = fos;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetOptions(FILEOPENDIALOGOPTIONS* pfos)
+{
+ cout << "GetOptions, fos: " << _fos << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->GetOptions(pfos);
+#endif
+ * pfos = _fos;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetDefaultFolder(IShellItem* psi)
+{
+ PWSTR pszPath = NULL;
+ if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath)))
+ {
+ wcout << L"SetDefaultFolder, psi: " << pszPath << endl;
+ CoTaskMemFree(pszPath);
+ }
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetDefaultFolder(psi);
+#endif
+ if (_initFolder)
+ {
+ _initFolder->Release();
+ }
+ _initFolder = CloneShellItem(psi);
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetFolder(IShellItem* psi)
+{
+ PWSTR pszPath = NULL;
+ if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath)))
+ {
+ wcout << L"SetFolder, psi: " << pszPath << endl;
+ CoTaskMemFree(pszPath);
+ }
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetFolder(psi);
+#endif
+ if (_initFolder)
+ {
+ _initFolder->Release();
+ }
+ _initFolder = CloneShellItem(psi);
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetFolder(IShellItem** ppsi)
+{
+ cout << "GetFolder" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->GetFolder(ppsi);
+#endif
+ * ppsi = NULL;
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetCurrentSelection(IShellItem** ppsi)
+{
+ cout << "GetCurrentSelection" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->GetCurrentSelection(ppsi);
+#endif
+ return GetResult(ppsi);
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetFileName(LPCWSTR pszName)
+{
+ wcout << L"SetFileName, pszName: " << pszName << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetFileName(pszName);
+#endif
+ std::wstring absPath = std::wstring(pszName);
+ _initName = absPath.substr(absPath.find_last_of(L"/\\") + 1);
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetFileName(LPWSTR* pszName)
+{
+ cout << "GetFileName" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->GetFileName(pszName);
+#endif
+ SHStrDupW(L"", pszName);
+ if (!_selectedItem.empty())
+ {
+ SHStrDupW(_selectedItem.c_str(), pszName);
+ }
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetTitle(LPCWSTR pszTitle)
+{
+ wcout << L"SetTitle, title: " << pszTitle << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetTitle(pszTitle);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetOkButtonLabel(LPCWSTR pszText)
+{
+ wcout << L"SetOkButtonLabel, pszText: " << pszText << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetOkButtonLabel(pszText);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetFileNameLabel(LPCWSTR pszLabel)
+{
+ wcout << L"SetFileNameLabel, pszLabel: " << pszLabel << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetFileNameLabel(pszLabel);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetResult(IShellItem** ppsi)
+{
+ cout << "GetResult" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->GetResult(ppsi);
+#endif
+ if (!_selectedItem.empty())
+ {
+ SHCreateItemFromParsingName(_selectedItem.c_str(), NULL, IID_IShellItem, (void**)ppsi);
+ return S_OK;
+ }
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AddPlace(IShellItem* psi, FDAP fdap)
+{
+ PWSTR pszPath = NULL;
+ if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath)))
+ {
+ wcout << L"AddPlace, psi: " << pszPath << endl;
+ CoTaskMemFree(pszPath);
+ }
+#ifdef SYSTEMDIALOG
+ return _systemDialog->AddPlace(psi, fdap);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetDefaultExtension(LPCWSTR pszDefaultExtension)
+{
+ wcout << L"SetDefaultExtension, pszDefaultExtension: " << pszDefaultExtension << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetDefaultExtension(pszDefaultExtension);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::Close(HRESULT hr)
+{
+ cout << "Close, hr: " << hr << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->Close(hr);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetClientGuid(REFGUID guid)
+{
+ cout << "SetClientGuid" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetClientGuid(guid);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::ClearClientData(void)
+{
+ cout << "ClearClientData" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->ClearClientData();
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetFilter(IShellItemFilter* pFilter)
+{
+ cout << "SetFilter" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetFilter(pFilter);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetCancelButtonLabel(LPCWSTR pszLabel)
+{
+ cout << "SetCancelButtonLabel" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetCancelButtonLabel(pszLabel);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetNavigationRoot(IShellItem* psi)
+{
+ cout << "SetNavigationRoot" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetNavigationRoot(psi);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::HideControlsForHostedPickerProviderApp(void)
+{
+ cout << "HideControlsForHostedPickerProviderApp" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->HideControlsForHostedPickerProviderApp();
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::EnableControlsForHostedPickerProviderApp(void)
+{
+ cout << "EnableControlsForHostedPickerProviderApp" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->EnableControlsForHostedPickerProviderApp();
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetPrivateOptions(unsigned long* pfos)
+{
+ cout << "GetPrivateOptions" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetPrivateOptions(pfos);
+#endif
+ * pfos = 0;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetPrivateOptions(unsigned long fos)
+{
+ cout << "SetPrivateOptions" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetPrivateOptions(fos);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetPersistenceKey(unsigned short const* pkey)
+{
+ cout << "SetPersistenceKey" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetPersistenceKey(pkey);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::HasPlaces(void)
+{
+ cout << "HasPlaces" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->HasPlaces();
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::EnumPlaces(int plc, _GUID const& riid, void** ppv)
+{
+ cout << "EnumPlaces" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->EnumPlaces(plc, riid, ppv);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::EnumControls(void** ppv)
+{
+ cout << "EnumControls" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->EnumControls(ppv);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetPersistRegkey(unsigned short** preg)
+{
+ cout << "GetPersistRegkey" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetPersistRegkey(preg);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetSavePropertyStore(IPropertyStore** ppstore, IPropertyDescriptionList** ppdesclist)
+{
+ cout << "GetSavePropertyStore" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetSavePropertyStore(ppstore, ppdesclist);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetSaveExtension(unsigned short** pext)
+{
+ cout << "GetSaveExtension" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetSaveExtension(pext);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetFileTypeControl(void** ftp)
+{
+ cout << "GetFileTypeControl" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetFileTypeControl(ftp);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetFileNameControl(void** pctrl)
+{
+ cout << "GetFileNameControl" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetFileNameControl(pctrl);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetFileProtectionControl(void** pfctrl)
+{
+ cout << "GetFileProtectionControl" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetFileProtectionControl(pfctrl);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetFolderPrivate(IShellItem* psi, int arg)
+{
+ cout << "SetFolderPrivate" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetFolderPrivate(psi, arg);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetCustomControlAreaHeight(unsigned int height)
+{
+ cout << "SetCustomControlAreaHeight" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetCustomControlAreaHeight(height);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetDialogState(unsigned long arg, unsigned long* pstate)
+{
+ cout << "GetDialogState" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetDialogState(arg, pstate);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetAppControlsModule(void* papp)
+{
+ cout << "SetAppControlsModule" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetAppControlsModule(papp);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetUserEditedSaveProperties(void)
+{
+ cout << "SetUserEditedSaveProperties" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetUserEditedSaveProperties();
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::ShouldShowStandardNavigationRoots(void)
+{
+ cout << "ShouldShowStandardNavigationRoots" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->ShouldShowStandardNavigationRoots();
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetNavigationRoot(_GUID const& riid, void** ppv)
+{
+ cout << "GetNavigationRoot" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetNavigationRoot(riid, ppv);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::ShouldShowFileProtectionControl(int* pfpc)
+{
+ cout << "ShouldShowFileProtectionControl" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->ShouldShowFileProtectionControl(pfpc);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetCurrentDialogView(_GUID const& riid, void** ppv)
+{
+ cout << "GetCurrentDialogView" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetCurrentDialogView(riid, ppv);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetSaveDialogEditBoxTextAndFileType(int arg, unsigned short const* pargb)
+{
+ cout << "SetSaveDialogEditBoxTextAndFileType" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->SetSaveDialogEditBoxTextAndFileType(arg, pargb);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::MoveFocusFromBrowser(int arg)
+{
+ cout << "MoveFocusFromBrowser" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->MoveFocusFromBrowser(arg);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::EnableOkButton(int enbl)
+{
+ cout << "EnableOkButton" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->EnableOkButton(enbl);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::InitEnterpriseId(unsigned short const* pid)
+{
+ cout << "InitEnterpriseId" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->InitEnterpriseId(pid);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::AdviseFirst(IFileDialogEvents* pfde, unsigned long* pdwCookie)
+{
+ cout << "AdviseFirst" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->AdviseFirst(pfde, pdwCookie);
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::HandleTab(void)
+{
+ cout << "HandleTab" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->HandleTab();
+#endif
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetSaveAsItem(IShellItem* psi)
+{
+ PWSTR pszPath = NULL;
+ if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszPath)))
+ {
+ wcout << L"SetSaveAsItem, psi: " << pszPath << endl;
+ CoTaskMemFree(pszPath);
+ }
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetSaveAsItem(psi);
+#endif
+ if (_initFolder)
+ {
+ _initFolder->Release();
+ }
+ psi->GetParent(&_initFolder);
+ if (SUCCEEDED(psi->GetDisplayName(SIGDN_NORMALDISPLAY, &pszPath)))
+ {
+ _initName = pszPath;
+ }
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetProperties(IPropertyStore* pStore)
+{
+ cout << "SetProperties" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetProperties(pStore);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::SetCollectedProperties(IPropertyDescriptionList* pList, BOOL fAppendDefault)
+{
+ cout << "SetCollectedProperties" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->SetCollectedProperties(pList, fAppendDefault);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetProperties(IPropertyStore** ppStore)
+{
+ cout << "GetProperties" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->GetProperties(ppStore);
+#endif
+ if (!_selectedItem.empty())
+ {
+ return SHGetPropertyStoreFromParsingName(_selectedItem.c_str(),
+ NULL, GPS_DEFAULT, __uuidof(IPropertyStore), (void**)ppStore);
+ }
+ return E_NOTIMPL;
+}
+
+HRESULT __stdcall CFilesSaveDialog::ApplyProperties(IShellItem* psi, IPropertyStore* pStore, HWND hwnd, IFileOperationProgressSink* pSink)
+{
+ cout << "ApplyProperties" << endl;
+#ifdef SYSTEMDIALOG
+ return _systemDialog->ApplyProperties(psi, pStore, hwnd, pSink);
+#endif
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::GetWindow(HWND* phwnd)
+{
+ cout << "GetWindow" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->GetWindow(phwnd);
+#endif
+ * phwnd = NULL;
+ return S_OK;
+}
+
+HRESULT __stdcall CFilesSaveDialog::ContextSensitiveHelp(BOOL fEnterMode)
+{
+ cout << "ContextSensitiveHelp" << endl;
+#ifdef SYSTEMDIALOG
+ return AsInterface(_systemDialog)->ContextSensitiveHelp(fEnterMode);
+#endif
+ return S_OK;
+}
diff --git a/src/Files.App.SaveDialog/FilesSaveDialog.h b/src/Files.App.SaveDialog/FilesSaveDialog.h
new file mode 100644
index 000000000000..85908dd50882
--- /dev/null
+++ b/src/Files.App.SaveDialog/FilesSaveDialog.h
@@ -0,0 +1,273 @@
+// FilesSaveDialog.h: dichiarazione di CFilesSaveDialog
+
+#pragma once
+#include "resource.h" // simboli principali
+
+
+#define DEBUGLOG
+
+
+#include "CustomSaveDialog_i.h"
+#include "UndefInterfaces.h"
+#include
+#include
+#include
+
+
+#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
+#error "Gli oggetti COM a thread singolo non sono supportati correttamente sulla piattaforma Windows CE, ad esempio le piattaforme Windows Mobile non includono un supporto DCOM completo. Definire _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA per fare in modo che ATL supporti la creazione di oggetti COM a thread singolo e consenta l'utilizzo di implementazioni con oggetti COM a thread singolo. Il modello di threading nel file RGS è stato impostato su 'Free' poiché è l'unico modello di threading supportato sulle piattaforme Windows CE non DCOM."
+#endif
+
+using namespace ATL;
+
+
+// CFilesSaveDialog
+
+class ATL_NO_VTABLE CFilesSaveDialog :
+ public CComObjectRootEx,
+ public CComCoClass,
+ public IFileDialog,
+ public IFileDialog2,
+ public IFileSaveDialog,
+ public IFileDialogCustomize,
+ public IObjectWithSite,
+ public IFileDialogPrivate,
+ public IOleWindow
+{
+public:
+ CFilesSaveDialog();
+
+DECLARE_REGISTRY_RESOURCEID(106)
+
+CUSTOM_BEGIN_COM_MAP(CFilesSaveDialog)
+ COM_INTERFACE_ENTRY(IFileDialog)
+ COM_INTERFACE_ENTRY(IFileDialog2)
+ COM_INTERFACE_ENTRY(IFileSaveDialog)
+ COM_INTERFACE_ENTRY(IFileDialogCustomize)
+ COM_INTERFACE_ENTRY(IObjectWithSite)
+ COM_INTERFACE_ENTRY(IFileDialogPrivate)
+ COM_INTERFACE_ENTRY(IOleWindow)
+END_COM_MAP()
+
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ HRESULT FinalConstruct()
+ {
+ return S_OK;
+ }
+
+ void FinalRelease();
+
+ CComPtr _systemDialog;
+
+ FILEOPENDIALOGOPTIONS _fos;
+
+ std::vector _ctrlItems;
+
+ std::wstring _selectedItem;
+ std::wstring _outputPath;
+ std::wstring _initName;
+ IShellItem* _initFolder;
+ IFileDialogEvents* _dialogEvents;
+
+ FILE* _debugStream;
+
+public:
+ // Ereditato tramite IObjectWithSite
+ HRESULT __stdcall SetSite(IUnknown* pUnkSite) override;
+
+ HRESULT __stdcall GetSite(REFIID riid, void** ppvSite) override;
+
+
+ // Ereditato tramite IFileDialogCustomize
+ HRESULT __stdcall EnableOpenDropDown(DWORD dwIDCtl) override;
+
+ HRESULT __stdcall AddMenu(DWORD dwIDCtl, LPCWSTR pszLabel) override;
+
+ HRESULT __stdcall AddPushButton(DWORD dwIDCtl, LPCWSTR pszLabel) override;
+
+ HRESULT __stdcall AddComboBox(DWORD dwIDCtl) override;
+
+ HRESULT __stdcall AddRadioButtonList(DWORD dwIDCtl) override;
+
+ HRESULT __stdcall AddCheckButton(DWORD dwIDCtl, LPCWSTR pszLabel, BOOL bChecked) override;
+
+ HRESULT __stdcall AddEditBox(DWORD dwIDCtl, LPCWSTR pszText) override;
+
+ HRESULT __stdcall AddSeparator(DWORD dwIDCtl) override;
+
+ HRESULT __stdcall AddText(DWORD dwIDCtl, LPCWSTR pszText) override;
+
+ HRESULT __stdcall SetControlLabel(DWORD dwIDCtl, LPCWSTR pszLabel) override;
+
+ HRESULT __stdcall GetControlState(DWORD dwIDCtl, CDCONTROLSTATEF* pdwState) override;
+
+ HRESULT __stdcall SetControlState(DWORD dwIDCtl, CDCONTROLSTATEF dwState) override;
+
+ HRESULT __stdcall GetEditBoxText(DWORD dwIDCtl, WCHAR** ppszText) override;
+
+ HRESULT __stdcall SetEditBoxText(DWORD dwIDCtl, LPCWSTR pszText) override;
+
+ HRESULT __stdcall GetCheckButtonState(DWORD dwIDCtl, BOOL* pbChecked) override;
+
+ HRESULT __stdcall SetCheckButtonState(DWORD dwIDCtl, BOOL bChecked) override;
+
+ HRESULT __stdcall AddControlItem(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) override;
+
+ HRESULT __stdcall RemoveControlItem(DWORD dwIDCtl, DWORD dwIDItem) override;
+
+ HRESULT __stdcall RemoveAllControlItems(DWORD dwIDCtl) override;
+
+ HRESULT __stdcall GetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF* pdwState) override;
+
+ HRESULT __stdcall SetControlItemState(DWORD dwIDCtl, DWORD dwIDItem, CDCONTROLSTATEF dwState) override;
+
+ HRESULT __stdcall GetSelectedControlItem(DWORD dwIDCtl, DWORD* pdwIDItem) override;
+
+ HRESULT __stdcall SetSelectedControlItem(DWORD dwIDCtl, DWORD dwIDItem) override;
+
+ HRESULT __stdcall StartVisualGroup(DWORD dwIDCtl, LPCWSTR pszLabel) override;
+
+ HRESULT __stdcall EndVisualGroup(void) override;
+
+ HRESULT __stdcall MakeProminent(DWORD dwIDCtl) override;
+
+ HRESULT __stdcall SetControlItemText(DWORD dwIDCtl, DWORD dwIDItem, LPCWSTR pszLabel) override;
+
+
+ // Ereditato tramite IFileDialog
+ HRESULT __stdcall Show(HWND hwndOwner) override;
+
+ HRESULT __stdcall SetFileTypes(UINT cFileTypes, const COMDLG_FILTERSPEC* rgFilterSpec) override;
+
+ HRESULT __stdcall SetFileTypeIndex(UINT iFileType) override;
+
+ HRESULT __stdcall GetFileTypeIndex(UINT* piFileType) override;
+
+ HRESULT __stdcall Advise(IFileDialogEvents* pfde, DWORD* pdwCookie) override;
+
+ HRESULT __stdcall Unadvise(DWORD dwCookie) override;
+
+ HRESULT __stdcall SetOptions(FILEOPENDIALOGOPTIONS fos) override;
+
+ HRESULT __stdcall GetOptions(FILEOPENDIALOGOPTIONS* pfos) override;
+
+ HRESULT __stdcall SetDefaultFolder(IShellItem* psi) override;
+
+ HRESULT __stdcall SetFolder(IShellItem* psi) override;
+
+ HRESULT __stdcall GetFolder(IShellItem** ppsi) override;
+
+ HRESULT __stdcall GetCurrentSelection(IShellItem** ppsi) override;
+
+ HRESULT __stdcall SetFileName(LPCWSTR pszName) override;
+
+ HRESULT __stdcall GetFileName(LPWSTR* pszName) override;
+
+ HRESULT __stdcall SetTitle(LPCWSTR pszTitle) override;
+
+ HRESULT __stdcall SetOkButtonLabel(LPCWSTR pszText) override;
+
+ HRESULT __stdcall SetFileNameLabel(LPCWSTR pszLabel) override;
+
+ HRESULT __stdcall GetResult(IShellItem** ppsi) override;
+
+ HRESULT __stdcall AddPlace(IShellItem* psi, FDAP fdap) override;
+
+ HRESULT __stdcall SetDefaultExtension(LPCWSTR pszDefaultExtension) override;
+
+ HRESULT __stdcall Close(HRESULT hr) override;
+
+ HRESULT __stdcall SetClientGuid(REFGUID guid) override;
+
+ HRESULT __stdcall ClearClientData(void) override;
+
+ HRESULT __stdcall SetFilter(IShellItemFilter* pFilter) override;
+
+
+ // Ereditato tramite IFileDialog2
+ HRESULT __stdcall SetCancelButtonLabel(LPCWSTR pszLabel) override;
+
+ HRESULT __stdcall SetNavigationRoot(IShellItem* psi) override;
+
+
+ // Ereditato tramite IFileDialogPrivate
+ HRESULT __stdcall HideControlsForHostedPickerProviderApp(void) override;
+
+ HRESULT __stdcall EnableControlsForHostedPickerProviderApp(void) override;
+
+ HRESULT __stdcall GetPrivateOptions(unsigned long*) override;
+
+ HRESULT __stdcall SetPrivateOptions(unsigned long) override;
+
+ HRESULT __stdcall SetPersistenceKey(unsigned short const*) override;
+
+ HRESULT __stdcall HasPlaces(void) override;
+
+ HRESULT __stdcall EnumPlaces(int, _GUID const&, void**) override;
+
+ HRESULT __stdcall EnumControls(void**) override;
+
+ HRESULT __stdcall GetPersistRegkey(unsigned short**) override;
+
+ HRESULT __stdcall GetSavePropertyStore(IPropertyStore**, IPropertyDescriptionList**) override;
+
+ HRESULT __stdcall GetSaveExtension(unsigned short**) override;
+
+ HRESULT __stdcall GetFileTypeControl(void**) override;
+
+ HRESULT __stdcall GetFileNameControl(void**) override;
+
+ HRESULT __stdcall GetFileProtectionControl(void**) override;
+
+ HRESULT __stdcall SetFolderPrivate(IShellItem*, int) override;
+
+ HRESULT __stdcall SetCustomControlAreaHeight(unsigned int) override;
+
+ HRESULT __stdcall GetDialogState(unsigned long, unsigned long*) override;
+
+ HRESULT __stdcall SetAppControlsModule(void*) override;
+
+ HRESULT __stdcall SetUserEditedSaveProperties(void) override;
+
+ HRESULT __stdcall ShouldShowStandardNavigationRoots(void) override;
+
+ HRESULT __stdcall GetNavigationRoot(_GUID const&, void**) override;
+
+ HRESULT __stdcall ShouldShowFileProtectionControl(int*) override;
+
+ HRESULT __stdcall GetCurrentDialogView(_GUID const&, void**) override;
+
+ HRESULT __stdcall SetSaveDialogEditBoxTextAndFileType(int, unsigned short const*) override;
+
+ HRESULT __stdcall MoveFocusFromBrowser(int) override;
+
+ HRESULT __stdcall EnableOkButton(int) override;
+
+ HRESULT __stdcall InitEnterpriseId(unsigned short const*) override;
+
+ HRESULT __stdcall AdviseFirst(IFileDialogEvents*, unsigned long*) override;
+
+ HRESULT __stdcall HandleTab(void) override;
+
+
+ // Ereditato tramite IFileSaveDialog
+ HRESULT __stdcall SetSaveAsItem(IShellItem* psi) override;
+
+ HRESULT __stdcall SetProperties(IPropertyStore* pStore) override;
+
+ HRESULT __stdcall SetCollectedProperties(IPropertyDescriptionList* pList, BOOL fAppendDefault) override;
+
+ HRESULT __stdcall GetProperties(IPropertyStore** ppStore) override;
+
+ HRESULT __stdcall ApplyProperties(IShellItem* psi, IPropertyStore* pStore, HWND hwnd, IFileOperationProgressSink* pSink) override;
+
+
+ // Ereditato tramite IOleWindow
+ virtual HRESULT __stdcall GetWindow(HWND* phwnd) override;
+
+ virtual HRESULT __stdcall ContextSensitiveHelp(BOOL fEnterMode) override;
+
+};
+
+OBJECT_ENTRY_AUTO(__uuidof(FilesSaveDialog), CFilesSaveDialog)
diff --git a/src/Files.App.SaveDialog/FilesSaveDialog.rgs b/src/Files.App.SaveDialog/FilesSaveDialog.rgs
new file mode 100644
index 000000000000..fc0a4b6e4351
--- /dev/null
+++ b/src/Files.App.SaveDialog/FilesSaveDialog.rgs
@@ -0,0 +1,16 @@
+HKCR
+{
+ NoRemove CLSID
+ {
+ ForceRemove {C0B4E2F3-BA21-4773-8DBA-335EC946EB8B} = s 'FilesSaveDialog class'
+ {
+ ForceRemove Programmable
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ TypeLib = s '{21533617-c1cd-4d33-a190-21fb069b55f4}'
+ Version = s '1.0'
+ }
+ }
+}
diff --git a/src/Files.App.SaveDialog/UndefInterfaces.h b/src/Files.App.SaveDialog/UndefInterfaces.h
new file mode 100644
index 000000000000..75dba8b174cd
--- /dev/null
+++ b/src/Files.App.SaveDialog/UndefInterfaces.h
@@ -0,0 +1,89 @@
+// UndefInterfaces.h: undocumented interfaces declarations & helpers
+
+#pragma once
+
+
+#include "framework.h"
+#include "shobjidl.h"
+
+
+using namespace ATL;
+
+
+#ifdef DEBUGLOG
+
+#define CUSTOM_BEGIN_COM_MAP(x) public: \
+ typedef x _ComMapClass; \
+ static HRESULT WINAPI _Cache(_In_ void* pv, _In_ REFIID iid, _COM_Outptr_result_maybenull_ void** ppvObject, _In_ DWORD_PTR dw) throw()\
+ {\
+ _ComMapClass* p = (_ComMapClass*)pv;\
+ p->Lock();\
+ HRESULT hRes = E_FAIL; \
+ __try \
+ { \
+ hRes = ATL::CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);\
+ } \
+ __finally \
+ { \
+ p->Unlock();\
+ } \
+ return hRes;\
+ }\
+ IUnknown* _GetRawUnknown() throw() \
+ { ATLASSERT(_GetEntries()[0].pFunc == _ATL_SIMPLEMAPENTRY); return (IUnknown*)((INT_PTR)this+_GetEntries()->dw); } \
+ _ATL_DECLARE_GET_UNKNOWN(x)\
+ HRESULT _InternalQueryInterface( \
+ _In_ REFIID iid, \
+ _COM_Outptr_ void** ppvObject) throw() \
+ { \
+ HRESULT res = this->InternalQueryInterface(this, _GetEntries(), iid, ppvObject); \
+ OLECHAR* guidString; \
+ (void)StringFromCLSID(iid, &guidString); \
+ std::wcout << L"QueryInterface: " << guidString << L" = " << res << std::endl; \
+ ::CoTaskMemFree(guidString); \
+ return res; \
+ } \
+ const static ATL::_ATL_INTMAP_ENTRY* WINAPI _GetEntries() throw() { \
+ static const ATL::_ATL_INTMAP_ENTRY _entries[] = { DEBUG_QI_ENTRY(x)
+
+#else
+
+#define CUSTOM_BEGIN_COM_MAP(x) BEGIN_COM_MAP(x)
+
+#endif // DEBUGLOG
+
+
+MIDL_INTERFACE("9EA5491C-89C8-4BEF-93D3-7F665FB82A33")
+IFileDialogPrivate : public IUnknown
+{
+public:
+ virtual HRESULT STDMETHODCALLTYPE HideControlsForHostedPickerProviderApp(void) = 0;
+ virtual HRESULT STDMETHODCALLTYPE EnableControlsForHostedPickerProviderApp(void) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetPrivateOptions(unsigned long*) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetPrivateOptions(unsigned long) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetPersistenceKey(unsigned short const*) = 0;
+ virtual HRESULT STDMETHODCALLTYPE HasPlaces(void) = 0;
+ virtual HRESULT STDMETHODCALLTYPE EnumPlaces(int, _GUID const&, void**) = 0;//tagFDPEPLACES
+ virtual HRESULT STDMETHODCALLTYPE EnumControls(void**) = 0;//IEnumAppControl
+ virtual HRESULT STDMETHODCALLTYPE GetPersistRegkey(unsigned short**) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetSavePropertyStore(IPropertyStore**, IPropertyDescriptionList**) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetSaveExtension(unsigned short**) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetFileTypeControl(void**) = 0;//IAppControl
+ virtual HRESULT STDMETHODCALLTYPE GetFileNameControl(void**) = 0;//IAppControl
+ virtual HRESULT STDMETHODCALLTYPE GetFileProtectionControl(void**) = 0;//IAppControl
+ virtual HRESULT STDMETHODCALLTYPE SetFolderPrivate(IShellItem*, int) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetCustomControlAreaHeight(unsigned int) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetDialogState(unsigned long, unsigned long*) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetAppControlsModule(void*) = 0;//IAppControlsModule
+ virtual HRESULT STDMETHODCALLTYPE SetUserEditedSaveProperties(void) = 0;
+ virtual HRESULT STDMETHODCALLTYPE ShouldShowStandardNavigationRoots(void) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetNavigationRoot(_GUID const&, void**) = 0;
+ virtual HRESULT STDMETHODCALLTYPE ShouldShowFileProtectionControl(int*) = 0;
+ virtual HRESULT STDMETHODCALLTYPE GetCurrentDialogView(_GUID const&, void**) = 0;
+ virtual HRESULT STDMETHODCALLTYPE SetSaveDialogEditBoxTextAndFileType(int, unsigned short const*) = 0;
+ virtual HRESULT STDMETHODCALLTYPE MoveFocusFromBrowser(int) = 0;
+ virtual HRESULT STDMETHODCALLTYPE EnableOkButton(int) = 0;
+ virtual HRESULT STDMETHODCALLTYPE InitEnterpriseId(unsigned short const*) = 0;
+ virtual HRESULT STDMETHODCALLTYPE AdviseFirst(IFileDialogEvents*, unsigned long*) = 0;
+ virtual HRESULT STDMETHODCALLTYPE HandleTab(void) = 0;
+};
diff --git a/src/Files.App.SaveDialog/dllmain.cpp b/src/Files.App.SaveDialog/dllmain.cpp
new file mode 100644
index 000000000000..e3b584168b34
--- /dev/null
+++ b/src/Files.App.SaveDialog/dllmain.cpp
@@ -0,0 +1,16 @@
+// dllmain.cpp: implementazione di DllMain.
+
+#include "pch.h"
+#include "framework.h"
+#include "resource.h"
+#include "CustomSaveDialog_i.h"
+#include "dllmain.h"
+
+CCustomSaveDialogModule _AtlModule;
+
+// Punto di ingresso DLL
+extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+{
+ hInstance;
+ return _AtlModule.DllMain(dwReason, lpReserved);
+}
diff --git a/src/Files.App.SaveDialog/dllmain.h b/src/Files.App.SaveDialog/dllmain.h
new file mode 100644
index 000000000000..284a990fe6d1
--- /dev/null
+++ b/src/Files.App.SaveDialog/dllmain.h
@@ -0,0 +1,10 @@
+// dllmain.h: dichiarazione della classe del modulo.
+
+class CCustomSaveDialogModule : public ATL::CAtlDllModuleT< CCustomSaveDialogModule >
+{
+public :
+ DECLARE_LIBID(LIBID_CustomSaveDialogLib)
+ DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CUSTOMSAVEDIALOG, "{21533617-c1cd-4d33-a190-21fb069b55f4}")
+};
+
+extern class CCustomSaveDialogModule _AtlModule;
diff --git a/src/Files.App.SaveDialog/framework.h b/src/Files.App.SaveDialog/framework.h
new file mode 100644
index 000000000000..9ac7cffd8ddd
--- /dev/null
+++ b/src/Files.App.SaveDialog/framework.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#ifndef STRICT
+#define STRICT
+#endif
+
+#include "targetver.h"
+
+#define _ATL_APARTMENT_THREADED
+
+#define _ATL_NO_AUTOMATIC_NAMESPACE
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // alcuni costruttori CString saranno espliciti
+
+
+#define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW
+
+#include "resource.h"
+#include
+#include
+#include
diff --git a/src/Files.App.SaveDialog/pch.cpp b/src/Files.App.SaveDialog/pch.cpp
new file mode 100644
index 000000000000..69046d3e1dc0
--- /dev/null
+++ b/src/Files.App.SaveDialog/pch.cpp
@@ -0,0 +1,5 @@
+// pch.cpp: file di origine corrispondente all'intestazione precompilata
+
+#include "pch.h"
+
+// Quando si usano intestazioni precompilate, questo file è necessario per la riuscita della compilazione.
diff --git a/src/Files.App.SaveDialog/pch.h b/src/Files.App.SaveDialog/pch.h
new file mode 100644
index 000000000000..aa5d1c5a0950
--- /dev/null
+++ b/src/Files.App.SaveDialog/pch.h
@@ -0,0 +1,13 @@
+// pch.h: questo è un file di intestazione precompilata.
+// I file elencati di seguito vengono compilati una sola volta, in modo da migliorare le prestazioni per le compilazioni successive.
+// Questa impostazione influisce anche sulle prestazioni di IntelliSense, incluso il completamento codice e molte altre funzionalità di esplorazione del codice.
+// I file elencati qui vengono però TUTTI ricompilati se uno di essi viene aggiornato da una compilazione all'altra.
+// Non aggiungere qui file soggetti a frequenti aggiornamenti; in caso contrario si perderanno i vantaggi offerti in termini di prestazioni.
+
+#ifndef PCH_H
+#define PCH_H
+
+// aggiungere qui le intestazioni da precompilare
+#include "framework.h"
+
+#endif //PCH_H
diff --git a/src/Files.App.SaveDialog/resource.h b/src/Files.App.SaveDialog/resource.h
new file mode 100644
index 000000000000..fbb30dbffe4e
--- /dev/null
+++ b/src/Files.App.SaveDialog/resource.h
@@ -0,0 +1,18 @@
+//{{NO_DEPENDENCIES}}
+// File di inclusione generato con Microsoft Visual C++.
+// Utilizzato da CustomSaveDialog.rc
+//
+#define IDS_PROJNAME 100
+#define IDR_CUSTOMSAVEDIALOG 101
+#define IDR_FILESSAVEDIALOG 106
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 201
+#define _APS_NEXT_COMMAND_VALUE 32768
+#define _APS_NEXT_CONTROL_VALUE 201
+#define _APS_NEXT_SYMED_VALUE 107
+#endif
+#endif
diff --git a/src/Files.App.SaveDialog/targetver.h b/src/Files.App.SaveDialog/targetver.h
new file mode 100644
index 000000000000..7672c2eee3bc
--- /dev/null
+++ b/src/Files.App.SaveDialog/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// L'inclusione di SDKDDKVer.h definisce la piattaforma Windows più recente disponibile.
+
+// Se si desidera compilare l'applicazione per una piattaforma Windows precedente, includere WinSDKVer.h e
+// impostare la macro _WIN32_WINNT sulla piattaforma da supportare prima di includere SDKDDKVer.h.
+
+#include
diff --git a/src/Files.App/App.xaml.cs b/src/Files.App/App.xaml.cs
index 5895b10b0fb3..7e4c0eb63ffe 100644
--- a/src/Files.App/App.xaml.cs
+++ b/src/Files.App/App.xaml.cs
@@ -211,6 +211,24 @@ private async void Window_Closed(object sender, WindowEventArgs args)
// Save the current tab list in case it was overwriten by another instance
AppLifecycleHelper.SaveSessionTabs();
+ if (OutputPath is not null)
+ {
+ var instance = MainPageViewModel.AppInstances.FirstOrDefault(x => x.TabItemContent.IsCurrentInstance);
+ if (instance is null)
+ return;
+
+ var items = (instance.TabItemContent as PaneHolderPage)?.ActivePane?.SlimContentPage?.SelectedItems;
+ if (items is null)
+ return;
+
+ var results = items.Select(x => x.ItemPath).ToList();
+ System.IO.File.WriteAllLines(OutputPath, results);
+
+ IntPtr eventHandle = Win32PInvoke.CreateEvent(IntPtr.Zero, false, false, "FILEDIALOG");
+ Win32PInvoke.SetEvent(eventHandle);
+ Win32PInvoke.CloseHandle(eventHandle);
+ }
+
// Continue running the app on the background
if (userSettingsService.GeneralSettingsService.LeaveAppRunning &&
!AppModel.ForceProcessTermination &&
@@ -292,23 +310,6 @@ private async void Window_Closed(object sender, WindowEventArgs args)
// Method can take a long time, make sure the window is hidden
await Task.Yield();
- if (OutputPath is not null)
- {
- await SafetyExtensions.IgnoreExceptions(async () =>
- {
- var instance = MainPageViewModel.AppInstances.FirstOrDefault(x => x.TabItemContent.IsCurrentInstance);
- if (instance is null)
- return;
-
- var items = (instance.TabItemContent as PaneHolderPage)?.ActivePane?.SlimContentPage?.SelectedItems;
- if (items is null)
- return;
-
- await FileIO.WriteLinesAsync(await StorageFile.GetFileFromPathAsync(OutputPath), items.Select(x => x.ItemPath));
- },
- Logger);
- }
-
// Try to maintain clipboard data after app close
SafetyExtensions.IgnoreExceptions(() =>
{
diff --git a/src/Files.App/Assets/FilesOpenDialog/CustomOpenDialog64.dll b/src/Files.App/Assets/FilesOpenDialog/CustomOpenDialog64.dll
deleted file mode 100644
index d860dba43d3f..000000000000
Binary files a/src/Files.App/Assets/FilesOpenDialog/CustomOpenDialog64.dll and /dev/null differ
diff --git a/src/Files.App/Program.cs b/src/Files.App/Program.cs
index f37b28c6ffa3..9ebbe468dbd7 100644
--- a/src/Files.App/Program.cs
+++ b/src/Files.App/Program.cs
@@ -62,11 +62,17 @@ private static void Main()
var OpenTabInExistingInstance = ApplicationData.Current.LocalSettings.Values.Get("OpenTabInExistingInstance", true);
var activatedArgs = AppInstance.GetCurrent().GetActivatedEventArgs();
- if (activatedArgs.Data is ICommandLineActivatedEventArgs cmdLineArgs)
+ // WINUI3: When launching from commandline the argument is not ICommandLineActivatedEventArgs (#10370)
+ var isCommadLineLaunch = activatedArgs.Data is ILaunchActivatedEventArgs args &&
+ args.Arguments is not null &&
+ (CommandLineParser.SplitArguments(args.Arguments, true)[0].EndsWith($"files.exe", StringComparison.OrdinalIgnoreCase)
+ || CommandLineParser.SplitArguments(args.Arguments, true)[0].EndsWith($"files", StringComparison.OrdinalIgnoreCase));
+
+ if (activatedArgs.Data is ICommandLineActivatedEventArgs || isCommadLineLaunch)
{
- var operation = cmdLineArgs.Operation;
- var cmdLineString = operation.Arguments;
- var parsedCommands = CommandLineParser.ParseUntrustedCommands(cmdLineString);
+ var cmdLineArgs = activatedArgs.Data as ICommandLineActivatedEventArgs;
+ var cmdLineLaunchArgs = activatedArgs.Data as ILaunchActivatedEventArgs;
+ var parsedCommands = CommandLineParser.ParseUntrustedCommands(cmdLineArgs?.Operation.Arguments ?? cmdLineLaunchArgs!.Arguments);
if (parsedCommands is not null)
{
@@ -119,7 +125,7 @@ private static void Main()
}
}
- if (OpenTabInExistingInstance)
+ if (OpenTabInExistingInstance && !isCommadLineLaunch)
{
if (activatedArgs.Data is ILaunchActivatedEventArgs launchArgs)
{
diff --git a/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs b/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs
index 7b7c3d487948..f32132f66484 100644
--- a/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs
+++ b/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs
@@ -135,12 +135,18 @@ private async Task SetAsOpenFileDialogAsync()
try
{
- using var regProc32 = Process.Start("regsvr32.exe", @$"/s /n {(!IsSetAsOpenFileDialog ? "/u" : "")} /i:user ""{Path.Combine(destFolder, "Files.App.OpenDialog32.dll")}""");
- await regProc32.WaitForExitAsync();
- using var regProc64 = Process.Start("regsvr32.exe", @$"/s /n {(!IsSetAsOpenFileDialog ? "/u" : "")} /i:user ""{Path.Combine(destFolder, "Files.App.OpenDialog64.dll")}""");
- await regProc64.WaitForExitAsync();
- using var regProcARM64 = Process.Start("regsvr32.exe", @$"/s /n {(!IsSetAsOpenFileDialog ? "/u" : "")} /i:user ""{Path.Combine(destFolder, "Files.App.OpenDialogARM64.dll")}""");
- await regProcARM64.WaitForExitAsync();
+ using (var regProc = Process.Start("regsvr32.exe", @$"/s /n {(!IsSetAsOpenFileDialog ? "/u" : "")} /i:user ""{Path.Combine(destFolder, "Files.App.OpenDialog32.dll")}"""))
+ await regProc.WaitForExitAsync();
+ using (var regProc = Process.Start("regsvr32.exe", @$"/s /n {(!IsSetAsOpenFileDialog ? "/u" : "")} /i:user ""{Path.Combine(destFolder, "Files.App.OpenDialog64.dll")}"""))
+ await regProc.WaitForExitAsync();
+ using (var regProc = Process.Start("regsvr32.exe", @$"/s /n {(!IsSetAsOpenFileDialog ? "/u" : "")} /i:user ""{Path.Combine(destFolder, "Files.App.OpenDialogARM64.dll")}"""))
+ await regProc.WaitForExitAsync();
+ using (var regProc = Process.Start("regsvr32.exe", @$"/s /n {(!IsSetAsOpenFileDialog ? "/u" : "")} /i:user ""{Path.Combine(destFolder, "Files.App.SaveDialog32.dll")}"""))
+ await regProc.WaitForExitAsync();
+ using (var regProc = Process.Start("regsvr32.exe", @$"/s /n {(!IsSetAsOpenFileDialog ? "/u" : "")} /i:user ""{Path.Combine(destFolder, "Files.App.SaveDialog64.dll")}"""))
+ await regProc.WaitForExitAsync();
+ using (var regProc = Process.Start("regsvr32.exe", @$"/s /n {(!IsSetAsOpenFileDialog ? "/u" : "")} /i:user ""{Path.Combine(destFolder, "Files.App.SaveDialogARM64.dll")}"""))
+ await regProc.WaitForExitAsync();
}
catch
{
@@ -248,9 +254,13 @@ private bool DetectIsSetAsDefaultFileManager()
private bool DetectIsSetAsOpenFileDialog()
{
- using var subkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Classes\CLSID\{DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7}");
+ using var subkeyOpen = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Classes\CLSID\{DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7}");
+ using var subkeySave = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Classes\CLSID\{C0B4E2F3-BA21-4773-8DBA-335EC946EB8B}");
- return subkey?.GetValue(string.Empty) as string == "FilesOpenDialog class";
+ var isSetAsOpenDialog = subkeyOpen?.GetValue(string.Empty) as string == "FilesOpenDialog class";
+ var isSetAsSaveDialog = subkeySave?.GetValue(string.Empty) as string == "FilesSaveDialog class";
+
+ return isSetAsOpenDialog || isSetAsSaveDialog;
}
private bool isSetAsDefaultFileManager;
@@ -267,6 +277,11 @@ public bool IsSetAsOpenFileDialog
set => SetProperty(ref isSetAsOpenFileDialog, value);
}
+ public bool CanShowSetAsOpenFileDialog
+ {
+ get => AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev;
+ }
+
private FileSavePicker InitializeWithWindow(FileSavePicker obj)
{
WinRT.Interop.InitializeWithWindow.Initialize(obj, MainWindow.Instance.WindowHandle);
diff --git a/src/Files.App/Views/Settings/AdvancedPage.xaml b/src/Files.App/Views/Settings/AdvancedPage.xaml
index 27717da5b219..7fae282bf0dd 100644
--- a/src/Files.App/Views/Settings/AdvancedPage.xaml
+++ b/src/Files.App/Views/Settings/AdvancedPage.xaml
@@ -163,7 +163,7 @@
x:Name="ReplaceOpenFileDialogSetting"
Title="{helpers:ResourceString Name=SettingsSetAsOpenDialog}"
HorizontalAlignment="Stretch"
- x:Load="False">
+ x:Load="{x:Bind ViewModel.CanShowSetAsOpenFileDialog}">