Add Open File DIalog (WIP)

This commit is contained in:
Sri Sham Haran 2022-10-26 21:06:09 +08:00
parent 1018454f2e
commit 3518004266
2 changed files with 41 additions and 0 deletions

View File

@ -21,6 +21,46 @@ namespace SHADE
std::vector<std::string> SHWinDialog::DisplayOpenDialog(OpenSaveConfig const& openSaveConfig) std::vector<std::string> SHWinDialog::DisplayOpenDialog(OpenSaveConfig const& openSaveConfig)
{ {
const HWND hwnd = GetDesktopWindow();
HRESULT hResult = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if(SUCCEEDED(hResult))
{
IFileOpenDialog* pFileOpen;
//Create Dialog object
hResult = CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_ALL, IID_IFileOpenDialog, reinterpret_cast<LPVOID*>(pFileOpen));
if(SUCCEEDED(hResult))
{
//Show the open dialog box
hResult = pFileOpen->Show(hwnd);
//Get file name from the dialoh box
if(SUCCEEDED(hResult))
{
if(openSaveConfig.openMultiple)
{
IShellItemArray* pItemArray;
hResult = pFileOpen->GetResults(&pItemArray);
if(SUCCEEDED(hResult))
{
}
}
else
{
IShellItem* pItem;
hResult = pFileOpen->GetResult(&pItem);
if(SUCCEEDED(hResult))
{
PWSTR pszFilePath;
hResult = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
}
}
}
}
}
return {}; return {};
} }

View File

@ -23,6 +23,7 @@ namespace SHADE
std::string title = "Open"; std::string title = "Open";
bool openFolders = false; bool openFolders = false;
bool openMultiple = false;
FilterList filterList{}; FilterList filterList{};
}; };