From 3756ae7c8dc60d459511d0b067ebef5efb052746 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 10 Aug 2022 19:24:24 -0500 Subject: Use IFileOpenDialog instead of SHBrowseForFolder and GetOpenFileName. It is the recommended option since Vista and has better long path support. --- src/tools/thmviewer/thmviewer.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'src/tools') diff --git a/src/tools/thmviewer/thmviewer.cpp b/src/tools/thmviewer/thmviewer.cpp index 38f3c4dc..4230dd35 100644 --- a/src/tools/thmviewer/thmviewer.cpp +++ b/src/tools/thmviewer/thmviewer.cpp @@ -66,6 +66,13 @@ static void CALLBACK ThmviewerTraceError( __in va_list args ); +static COMDLG_FILTERSPEC vrgFilters[] = +{ + { L"Theme Files (*.thm)", L"*.thm" }, + { L"XML Files (*.xml)", L"*.xml" }, + { L"All Files (*.*)", L"*.*" }, +}; + int WINAPI wWinMain( __in HINSTANCE hInstance, @@ -110,24 +117,8 @@ int WINAPI wWinMain( if (!sczThemeFile) { // Prompt for a path to the theme file. - OPENFILENAMEW ofn = { }; - WCHAR wzFile[MAX_PATH] = { }; - - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hWnd; - ofn.lpstrFile = wzFile; - ofn.nMaxFile = countof(wzFile); - ofn.lpstrFilter = L"Theme Files (*.thm)\0*.thm\0XML Files (*.xml)\0*.xml\0All Files (*.*)\0*.*\0"; - ofn.nFilterIndex = 1; - ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - ofn.lpstrTitle = vpTheme->sczCaption; - - if (::GetOpenFileNameW(&ofn)) - { - hr = StrAllocString(&sczThemeFile, wzFile, 0); - ExitOnFailure(hr, "Failed to copy opened file to theme file."); - } - else + hr = WnduShowOpenFileDialog(hWnd, TRUE, TRUE, vpTheme->sczCaption, vrgFilters, countof(vrgFilters), 1, NULL, &sczThemeFile); + if (FAILED(hr)) { ::MessageBoxW(hWnd, L"Must specify a path to theme file.", vpTheme->sczCaption, MB_OK | MB_ICONERROR); ExitFunction1(hr = E_INVALIDARG); -- cgit v1.2.3-55-g6feb