mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 14:08:22 +00:00
[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.
This commit is contained in:
parent
12dfa8ce39
commit
7e6550b35e
5 changed files with 133 additions and 0 deletions
|
@ -7,6 +7,7 @@ include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
|
||||||
spec2def(comdlg32.dll comdlg32.spec ADD_IMPORTLIB)
|
spec2def(comdlg32.dll comdlg32.spec ADD_IMPORTLIB)
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
|
autocomp.cpp
|
||||||
cdlg32.c
|
cdlg32.c
|
||||||
colordlg.c
|
colordlg.c
|
||||||
filedlg.c
|
filedlg.c
|
||||||
|
|
115
dll/win32/comdlg32/autocomp.cpp
Normal file
115
dll/win32/comdlg32/autocomp.cpp
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -79,6 +79,8 @@
|
||||||
#include "wine/heap.h"
|
#include "wine/heap.h"
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
#include "wine/unicode.h"
|
#include "wine/unicode.h"
|
||||||
|
EXTERN_C HRESULT DoInitAutoCompleteWithCWD(FileOpenDlgInfos *pInfo, HWND hwndEdit);
|
||||||
|
EXTERN_C HRESULT DoReleaseAutoCompleteWithCWD(FileOpenDlgInfos *pInfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
||||||
|
@ -1558,6 +1560,7 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||||
s_hFileDialogHook = NULL;
|
s_hFileDialogHook = NULL;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&COMDLG32_OpenFileLock);
|
LeaveCriticalSection(&COMDLG32_OpenFileLock);
|
||||||
|
DoReleaseAutoCompleteWithCWD(fodInfos);
|
||||||
#endif
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2030,6 +2033,9 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
|
||||||
|
|
||||||
/* Initialize the filter combo box */
|
/* Initialize the filter combo box */
|
||||||
FILEDLG95_FILETYPE_Init(hwnd);
|
FILEDLG95_FILETYPE_Init(hwnd);
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
DoInitAutoCompleteWithCWD(fodInfos, fodInfos->DlgInfos.hwndFileName);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,9 @@
|
||||||
#include "servprov.h"
|
#include "servprov.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "wine/heap.h"
|
#include "wine/heap.h"
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
EXTERN_C HRESULT DoUpdateAutoCompleteWithCWD(const FileOpenDlgInfos *info, LPCITEMIDLIST pidl);
|
||||||
|
#endif
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
||||||
|
|
||||||
|
@ -143,6 +146,9 @@ static void COMDLG32_UpdateCurrentDir(const FileOpenDlgInfos *fodInfos)
|
||||||
if (SUCCEEDED(res))
|
if (SUCCEEDED(res))
|
||||||
SetCurrentDirectoryW(wszCurrentDir);
|
SetCurrentDirectoryW(wszCurrentDir);
|
||||||
}
|
}
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
DoUpdateAutoCompleteWithCWD(fodInfos, fodInfos->ShellInfos.pidlAbsCurrent);
|
||||||
|
#endif
|
||||||
|
|
||||||
IShellFolder_Release(psfDesktop);
|
IShellFolder_Release(psfDesktop);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,11 @@ typedef struct
|
||||||
|
|
||||||
BOOL ole_initialized;
|
BOOL ole_initialized;
|
||||||
LPITEMIDLIST places[5];
|
LPITEMIDLIST places[5];
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
LPVOID pvCWD; /* ICurrentWorkingDirectory */
|
||||||
|
LPVOID pvDropDown; /* IAutoCompleteDropDown */
|
||||||
|
LPVOID pvACList; /* IACList2 */
|
||||||
|
#endif
|
||||||
} FileOpenDlgInfos;
|
} FileOpenDlgInfos;
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
Loading…
Reference in a new issue