https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7e6550b35e306b39148965...
commit 7e6550b35e306b39148965632d60d3509c352d02 Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Thu Apr 1 06:41:24 2021 +0900 Commit: GitHub noreply@github.com CommitDate: Thu Apr 1 06:41:24 2021 +0900
[COMDLG32] Enable auto-completion on comdlg32 (#3564)
Auto-completion will be enabled when the user opens "Open" or "Save As" dialog of the common dialogs. CORE-9281
NOTE: The relative pathes, ".." and "" are not working. Those are bugs in CLSID_ACListISF. --- dll/win32/comdlg32/CMakeLists.txt | 1 + dll/win32/comdlg32/autocomp.cpp | 115 ++++++++++++++++++++++++++++++++++++ dll/win32/comdlg32/filedlg.c | 6 ++ dll/win32/comdlg32/filedlgbrowser.c | 6 ++ dll/win32/comdlg32/filedlgbrowser.h | 5 ++ 5 files changed, 133 insertions(+)
diff --git a/dll/win32/comdlg32/CMakeLists.txt b/dll/win32/comdlg32/CMakeLists.txt index bb87894e2c8..a0f2d69ca75 100644 --- a/dll/win32/comdlg32/CMakeLists.txt +++ b/dll/win32/comdlg32/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) spec2def(comdlg32.dll comdlg32.spec ADD_IMPORTLIB)
list(APPEND SOURCE + autocomp.cpp cdlg32.c colordlg.c filedlg.c diff --git a/dll/win32/comdlg32/autocomp.cpp b/dll/win32/comdlg32/autocomp.cpp new file mode 100644 index 00000000000..f5762a23246 --- /dev/null +++ b/dll/win32/comdlg32/autocomp.cpp @@ -0,0 +1,115 @@ +/* + * PROJECT: ReactOS Common Dialogs + * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) + * PURPOSE: Implement auto-completion for comdlg32 + * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com + */ +#include "precomp.h" + +WINE_DEFAULT_DEBUG_CHANNEL(commdlg); + +EXTERN_C HRESULT +DoInitAutoCompleteWithCWD(FileOpenDlgInfos *pInfo, HWND hwndEdit) +{ + pInfo->pvCWD = pInfo->pvDropDown = pInfo->pvACList = NULL; + + WCHAR szClass[32]; + GetClassNameW(hwndEdit, szClass, _countof(szClass)); + if (lstrcmpiW(szClass, WC_COMBOBOXW) == 0) + { + COMBOBOXINFO info = { sizeof(info) }; + GetComboBoxInfo(hwndEdit, &info); + hwndEdit = info.hwndItem; + } + else if (lstrcmpiW(szClass, WC_COMBOBOXEXW) == 0) + { + hwndEdit = (HWND)SendMessageW(hwndEdit, CBEM_GETEDITCONTROL, 0, 0); + } + + IACList2 *pACList = NULL; + HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_INPROC_SERVER, + IID_IACList2, reinterpret_cast<LPVOID *>(&pACList)); + if (FAILED(hr)) + { + TRACE("CoCreateInstance(CLSID_ACListISF): 0x%08lX\n", hr); + return hr; + } + pInfo->pvACList = static_cast<LPVOID>(pACList); + + IAutoComplete2 *pAC = NULL; + hr = CoCreateInstance(CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER, + IID_IAutoComplete2, reinterpret_cast<LPVOID *>(&pAC)); + if (SUCCEEDED(hr)) + { + pAC->Init(hwndEdit, pACList, NULL, NULL); + pAC->SetOptions(ACO_AUTOSUGGEST); + pAC->QueryInterface(IID_IAutoCompleteDropDown, &pInfo->pvDropDown); + pAC->Release(); + } + else + { + TRACE("CoCreateInstance(CLSID_AutoComplete): 0x%08lX\n", hr); + pACList->Release(); + pInfo->pvACList = NULL; + return hr; + } + + pACList->QueryInterface(IID_ICurrentWorkingDirectory, &pInfo->pvCWD); + + return hr; +} + +EXTERN_C HRESULT +DoUpdateAutoCompleteWithCWD(const FileOpenDlgInfos *info, LPCITEMIDLIST pidl) +{ + FileOpenDlgInfos *pInfo = const_cast<FileOpenDlgInfos*>(info); + if (!pInfo) + return E_POINTER; + + ICurrentWorkingDirectory* pCWD = + reinterpret_cast<ICurrentWorkingDirectory*>(pInfo->pvCWD); + + IAutoCompleteDropDown* pDropDown = + reinterpret_cast<IAutoCompleteDropDown*>(pInfo->pvDropDown); + + IACList2* pACList = static_cast<IACList2*>(pInfo->pvACList); + + WCHAR szPath[MAX_PATH]; + if (!pidl || !SHGetPathFromIDListW(pidl, szPath)) + { + GetCurrentDirectoryW(_countof(szPath), szPath); + } + + if (pCWD) + pCWD->SetDirectory(szPath); + if (pDropDown) + pDropDown->ResetEnumerator(); + if (pACList) + pACList->Expand(L""); + + return S_OK; +} + +EXTERN_C HRESULT +DoReleaseAutoCompleteWithCWD(FileOpenDlgInfos *pInfo) +{ + if (!pInfo) + return E_POINTER; + + ICurrentWorkingDirectory* pCWD = + reinterpret_cast<ICurrentWorkingDirectory*>(pInfo->pvCWD); + if (pCWD) + pCWD->Release(); + + IAutoCompleteDropDown* pDropDown = + reinterpret_cast<IAutoCompleteDropDown*>(pInfo->pvDropDown); + if (pDropDown) + pDropDown->Release(); + + IACList2 *pACList = static_cast<IACList2*>(pInfo->pvACList); + if (pACList) + pACList->Release(); + + pInfo->pvCWD = pInfo->pvDropDown = pInfo->pvACList = NULL; + return S_OK; +} diff --git a/dll/win32/comdlg32/filedlg.c b/dll/win32/comdlg32/filedlg.c index 49bd1d006b1..cf1d2bc34c2 100644 --- a/dll/win32/comdlg32/filedlg.c +++ b/dll/win32/comdlg32/filedlg.c @@ -79,6 +79,8 @@ #include "wine/heap.h" #ifdef __REACTOS__ #include "wine/unicode.h" +EXTERN_C HRESULT DoInitAutoCompleteWithCWD(FileOpenDlgInfos *pInfo, HWND hwndEdit); +EXTERN_C HRESULT DoReleaseAutoCompleteWithCWD(FileOpenDlgInfos *pInfo); #endif
WINE_DEFAULT_DEBUG_CHANNEL(commdlg); @@ -1558,6 +1560,7 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l s_hFileDialogHook = NULL; } LeaveCriticalSection(&COMDLG32_OpenFileLock); + DoReleaseAutoCompleteWithCWD(fodInfos); #endif return FALSE; } @@ -2030,6 +2033,9 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
/* Initialize the filter combo box */ FILEDLG95_FILETYPE_Init(hwnd); +#ifdef __REACTOS__ + DoInitAutoCompleteWithCWD(fodInfos, fodInfos->DlgInfos.hwndFileName); +#endif
return 0; } diff --git a/dll/win32/comdlg32/filedlgbrowser.c b/dll/win32/comdlg32/filedlgbrowser.c index 83d5f5e9e09..feaa5557ea7 100644 --- a/dll/win32/comdlg32/filedlgbrowser.c +++ b/dll/win32/comdlg32/filedlgbrowser.c @@ -41,6 +41,9 @@ #include "servprov.h" #include "wine/debug.h" #include "wine/heap.h" +#ifdef __REACTOS__ +EXTERN_C HRESULT DoUpdateAutoCompleteWithCWD(const FileOpenDlgInfos *info, LPCITEMIDLIST pidl); +#endif
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
@@ -143,6 +146,9 @@ static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos *fodInfos) if (SUCCEEDED(res)) SetCurrentDirectoryW(wszCurrentDir); } +#ifdef __REACTOS__ + DoUpdateAutoCompleteWithCWD(fodInfos, fodInfos->ShellInfos.pidlAbsCurrent); +#endif
IShellFolder_Release(psfDesktop); } diff --git a/dll/win32/comdlg32/filedlgbrowser.h b/dll/win32/comdlg32/filedlgbrowser.h index 21eb3d56dfe..67c07a8793c 100644 --- a/dll/win32/comdlg32/filedlgbrowser.h +++ b/dll/win32/comdlg32/filedlgbrowser.h @@ -94,6 +94,11 @@ typedef struct
BOOL ole_initialized; LPITEMIDLIST places[5]; +#ifdef __REACTOS__ + LPVOID pvCWD; /* ICurrentWorkingDirectory */ + LPVOID pvDropDown; /* IAutoCompleteDropDown */ + LPVOID pvACList; /* IACList2 */ +#endif } FileOpenDlgInfos;
/***********************************************************************